Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix self-contained warning #23705 #23999

Merged
merged 1 commit into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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