Skip to content

Commit

Permalink
fix self contained warning #23705
Browse files Browse the repository at this point in the history
  • Loading branch information
gkulin committed Feb 17, 2022
1 parent 8083ce5 commit 256deab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ Copyright (c) .NET Foundation. All rights reserved.
This avoids a breaking change from 1.0 behavior.
-->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(HasRuntimeOutput)' == 'true'">
<_SelfContainedWasSpecified Condition="'$(SelfContained)' != ''">true</_SelfContainedWasSpecified>
<SelfContained Condition="'$(SelfContained)' == '' and '$(RuntimeIdentifier)' != ''">true</SelfContained>
<SelfContained Condition="'$(SelfContained)' == ''">false</SelfContained>
<_RuntimeIdentifierUsesAppHost Condition="$(RuntimeIdentifier.StartsWith('ios')) or $(RuntimeIdentifier.StartsWith('tvos')) or $(RuntimeIdentifier.StartsWith('maccatalyst')) or $(RuntimeIdentifier.StartsWith('android')) or $(RuntimeIdentifier.StartsWith('browser'))">false</_RuntimeIdentifierUsesAppHost>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ Copyright (c) .NET Foundation. All rights reserved.
<Target Name="ValidateCommandLineProperties"
AfterTargets="_CheckForInvalidConfigurationAndPlatform" >

<NETSdkWarning Condition="'$(_CommandLineDefinedSelfContained)' != 'true' and
<NETSdkWarning Condition="'$(_SelfContainedWasSpecified)' != 'true' and
'$(_CommandLineDefinedRuntimeIdentifier)' == 'true' and
'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and
$([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '6.0'))"
Expand Down
21 changes: 21 additions & 0 deletions src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,27 @@ public void It_warns_on_rid_without_self_contained_options()
.HaveStdOutContaining("NETSDK1179");
}

[Fact]
public void It_does_not_warn_on_rid_with_self_contained_set_in_project()
{
var testProject = new TestProject()
{
IsExe = true,
TargetFrameworks = ToolsetInfo.CurrentTargetFramework,
};
testProject.AdditionalProperties["SelfContained"] = "true";

var testInstance = _testAssetsManager.CreateTestProject(testProject);

new DotnetBuildCommand(Log)
.WithWorkingDirectory(Path.Combine(testInstance.Path, testProject.Name))
.Execute("-r", "win-x64")
.Should()
.Pass()
.And
.NotHaveStdOutContaining("NETSDK1179");
}

[WindowsOnlyTheory]
[InlineData("build")]
[InlineData("run")]
Expand Down

0 comments on commit 256deab

Please sign in to comment.