diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets index b2065a93c44d..9acdab5b0041 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets @@ -67,6 +67,14 @@ Copyright (c) .NET Foundation. All rights reserved. $(PublishSelfContained) + - diff --git a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs index 1a0ead735614..8ca7b919d710 100644 --- a/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs +++ b/src/Tests/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildASelfContainedApp.cs @@ -408,13 +408,13 @@ public void It_does_not_build_SelfContained_due_to_PublishSelfContained_being_tr [InlineData("--p:PublishReadyToRun=true")] [InlineData("-p:PublishSingleFile=true")] [InlineData("-p:PublishSelfContained=true")] - [InlineData("-p:SelfContained=true")] + [InlineData("-p:PublishAot=true")] public void It_builds_without_implicit_rid_with_RuntimeIdentifier_specific_during_publish_only_properties(string property) { var tfm = ToolsetInfo.CurrentTargetFramework; var testProject = new TestProject() { - Name = "PublishImplicitRid", + IsExe = true, TargetFrameworks = tfm, }; testProject.RecordProperties("RuntimeIdentifier"); diff --git a/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs b/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs index c2871b869b4b..07414392a3cc 100644 --- a/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs +++ b/src/Tests/dotnet-build.Tests/GivenDotnetBuildBuildsCsproj.cs @@ -254,24 +254,30 @@ public void It_does_not_warn_on_rid_with_self_contained_options_prior_to_net6() [Theory] [InlineData("--self-contained")] - [InlineData("-p:PublishTrimmed=true")] - [InlineData("")] - public void It_builds_with_implicit_rid_with_rid_specific_properties(string executeOptionsAndProperties) + public void It_builds_with_implicit_rid_with_SelfContained(string executeOptions) { - var testInstance = _testAssetsManager.CopyTestAsset("HelloWorld") - .WithSource() - .WithTargetFrameworkOrFrameworks("net6.0", false) - .Restore(Log); + var targetFramework = ToolsetInfo.CurrentTargetFramework; + var testProject = new TestProject() + { + IsExe = true, + TargetFrameworks = targetFramework + }; - new DotnetBuildCommand(Log) - .WithWorkingDirectory(testInstance.Path) - .Execute(executeOptionsAndProperties) + testProject.RecordProperties("RuntimeIdentifier"); + var testAsset = _testAssetsManager.CreateTestProject(testProject); + + + new DotnetBuildCommand(Log, Path.Combine(testAsset.TestRoot, testProject.Name)) + .Execute(executeOptions) .Should() .Pass() .And .NotHaveStdOutContaining("NETSDK1031") // Self Contained Checks .And - .NotHaveStdErrContaining("NETSDK1190"); // Check that publish properties don't interfere with build either + .NotHaveStdErrContaining("NETSDK1190"); // Check that publish properties don't interfere with build either + + var properties = testProject.GetPropertyValues(testAsset.TestRoot, targetFramework: targetFramework); + Assert.NotEqual("", properties["RuntimeIdentifier"]); } [RequiresMSBuildVersionFact("17.4.0.41702")] diff --git a/src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetOsArchOptions.cs b/src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetOsArchOptions.cs index 49ca2bd8fffe..872f19968158 100644 --- a/src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetOsArchOptions.cs +++ b/src/Tests/dotnet.Tests/dotnet-msbuild/GivenDotnetOsArchOptions.cs @@ -143,36 +143,5 @@ public void CommandsRunWithArchOption(string command) .Should() .Pass(); } - - [Fact] - public void ItUsesImplicitRidWhenNoneIsSpecifiedForSelfContained() - { - CommandDirectoryContext.PerformActionWithBasePath(WorkingDirectory, () => - { - var msbuildPath = ""; - var currentRid = CommonOptions.GetCurrentRuntimeId(); - var command = BuildCommand.FromArgs(new string[] { "--self-contained" }, msbuildPath); - command.GetArgumentsToMSBuild() - .Should() - .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary " + - $"-property:SelfContained=True -property:_CommandLineDefinedSelfContained=true"); - }); - } - - [Fact] - public void ItDoesNotUseImplicitRidWhenOneIsSpecifiedForSelfContained() - { - CommandDirectoryContext.PerformActionWithBasePath(WorkingDirectory, () => - { - var msbuildPath = ""; - var currentRid = CommonOptions.GetCurrentRuntimeId(); - var command = BuildCommand.FromArgs(new string[] { "--self-contained", "--runtime", "fake-rid" }, msbuildPath); - command.GetArgumentsToMSBuild() - .Should() - .StartWith($"{ExpectedPrefix} -restore -consoleloggerparameters:Summary " + - $"-property:RuntimeIdentifier=fake-rid -property:_CommandLineDefinedRuntimeIdentifier=true " + - $"-property:SelfContained=True -property:_CommandLineDefinedSelfContained=true"); - }); - } } }