Skip to content

Commit 39efc99

Browse files
committed
update AOT tool test scenario and fix test breaks
1 parent 7d25694 commit 39efc99

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.PackTool.targets

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,31 @@ Copyright (c) .NET Foundation. All rights reserved.
2727
<IncludeBuildOutput>false</IncludeBuildOutput>
2828
<!-- the publish* properties _can_ be set, but only for the 'inner' RID-specific builds. We need to make sure that for the outer, agnostic build they are unset -->
2929
<PublishSelfContained Condition="'$(RuntimeIdentifier)' == ''">false</PublishSelfContained>
30+
<!-- Have to set SelfContained similarly because PackTool targets are imported _after_ RuntimeIdentifierInference targets, where the Publish* properties are
31+
forwarded to the 'base' properties. -->
32+
<SelfContained Condition="'$(RuntimeIdentifier)' == ''">false</SelfContained>
3033
<PublishTrimmed Condition="'$(RuntimeIdentifier)' == ''">false</PublishTrimmed>
3134
<PublishReadyToRun Condition="'$(RuntimeIdentifier)' == ''">false</PublishReadyToRun>
3235
<PublishAot Condition="'$(RuntimeIdentifier)' == ''">false</PublishAot>
3336

3437
<!-- we want to ensure that we don't publish any AppHosts for the 'outer', RID-agnostic builds -->
3538
<UseAppHost Condition="'$(RuntimeIdentifier)' == ''">false</UseAppHost>
39+
<!-- we want to ensure that we _do_ publish any AppHosts for the 'inner', RID-specific builds -->
40+
<UseAppHost Condition="'$(RuntimeIdentifier)' != ''">true</UseAppHost>
3641

3742
<!-- If shims are included, we need to make sure we restore for those RIDs so the apphost shims are available during restore/publish -->
3843
<_ToolRidsAreOnlyShims>false</_ToolRidsAreOnlyShims>
3944
<_ToolRidsAreOnlyShims Condition="'$(RuntimeIdentifiers)' == '' and $(PackAsToolShimRuntimeIdentifiers) != '' ">true</_ToolRidsAreOnlyShims>
40-
<RuntimeIdentifiers Condition="'$(PackAsToolShimRuntimeIdentifiers)' != ''">$(RuntimeIdentifiers);$(PackAsToolShimRuntimeIdentifiers)</RuntimeIdentifiers>
45+
<_UserSpecifiedToolPackageRids Condition="'$(ToolPackageRuntimeIdentifiers)' != ''">$(ToolPackageRuntimeIdentifiers)</_UserSpecifiedToolPackageRids>
46+
<_UserSpecifiedToolPackageRids Condition="'$(_UserSpecifiedToolPackageRids)' == ''">$(RuntimeIdentifiers)</_UserSpecifiedToolPackageRids>
47+
<RuntimeIdentifiers Condition="'$(PackAsToolShimRuntimeIdentifiers)' != ''">$(_UserSpecifiedToolPackageRids);$(PackAsToolShimRuntimeIdentifiers)</RuntimeIdentifiers>
4148

4249
<!-- Tool implementation files are not included in the primary package when the tool has RID-specific packages. So only pack the tool implementation
4350
(and only depend on publish) if there are no RID-specific packages, or if the RuntimeIdentifier is set. -->
4451
<_ToolPackageShouldIncludeImplementation Condition=" '$(PackAsTool)' == 'true' And
4552
('$(ToolPackageRuntimeIdentifiers)' == '' Or '$(RuntimeIdentifier)' != '')">true</_ToolPackageShouldIncludeImplementation>
4653
<_ToolPackageShouldIncludeImplementation Condition="'$(_ToolPackageShouldIncludeImplementation)' == ''">false</_ToolPackageShouldIncludeImplementation>
47-
<_HasRIDSpecificTools Condition=" '$(ToolPackageRuntimeIdentifiers)' != '' or ( '$(RuntimeIdentifiers)' != '' and $(_ToolRidsAreOnlyShims) == false ) ">true</_HasRIDSpecificTools>
54+
<_HasRIDSpecificTools Condition=" '$(_UserSpecifiedToolPackageRids)' != '' ">true</_HasRIDSpecificTools>
4855
<_HasRIDSpecificTools Condition="'$(_HasRIDSpecificTools)' == ''">false</_HasRIDSpecificTools>
4956

5057
<!-- inner builds and non-RID-specific outer builds need publish content-->
@@ -94,7 +101,7 @@ Copyright (c) .NET Foundation. All rights reserved.
94101
</PropertyGroup>
95102

96103
<!-- inner-build tool packages get a RID suffix -->
97-
<PropertyGroup Condition="'$(ToolPackageRuntimeIdentifiers)' != '' And '$(RuntimeIdentifier)' != ''">
104+
<PropertyGroup Condition="'$(_HasRIDSpecificTools)' != '' And '$(RuntimeIdentifier)' != ''">
98105
<PackageId>$(PackageId).$(RuntimeIdentifier)</PackageId>
99106
</PropertyGroup>
100107

@@ -156,7 +163,7 @@ Copyright (c) .NET Foundation. All rights reserved.
156163

157164
<Target Name="_GenerateToolsSettingsFileInputCache">
158165
<ItemGroup>
159-
<_ToolPackageRuntimeIdentifier Include="$(ToolRuntimeIdentifiers)" />
166+
<_ToolPackageRuntimeIdentifier Include="$(_UserSpecifiedToolPackageRids)" />
160167
<_GenerateToolsSettingsFileInputCacheToHash Include="$(ToolEntryPoint)" />
161168
<_GenerateToolsSettingsFileInputCacheToHash Include="$(ToolCommandName)" />
162169
<_GenerateToolsSettingsFileInputCacheToHash Include="$(ToolCommandRunner)" />

test/Microsoft.DotNet.PackageInstall.Tests/TestToolBuilder.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class TestToolSettings
4141
public string CreateTestTool(ITestOutputHelper log, TestToolSettings toolSettings)
4242
{
4343
var targetDirectory = Path.Combine(TestContext.Current.TestExecutionDirectory, "TestTools", toolSettings.GetIdentifier());
44-
44+
4545

4646
var testProject = new TestProject(toolSettings.ToolPackageId)
4747
{
@@ -56,7 +56,7 @@ public string CreateTestTool(ITestOutputHelper log, TestToolSettings toolSetting
5656
if (toolSettings.NativeAOT)
5757
{
5858
testProject.AdditionalProperties["PublishAot"] = "true";
59-
testProject.AddItem("ToolPackageRuntimeIdentifier", "Include", RuntimeInformation.RuntimeIdentifier);
59+
testProject.AdditionalProperties["RuntimeIdentifiers"] = RuntimeInformation.RuntimeIdentifier;
6060
}
6161

6262
testProject.SourceFiles.Add("Program.cs", "Console.WriteLine(\"Hello Tool!\");");
@@ -87,15 +87,15 @@ public string CreateTestTool(ITestOutputHelper log, TestToolSettings toolSetting
8787
{
8888
new DotnetPackCommand(log)
8989
.WithWorkingDirectory(targetDirectory)
90-
.Execute()
90+
.Execute("/bl:{}")
9191
.Should().Pass();
9292

9393
if (toolSettings.NativeAOT)
9494
{
9595
// For Native AOT tools, we need to repack the tool to include the runtime-specific files that were generated during publish
9696
new DotnetPackCommand(log, "-r", RuntimeInformation.RuntimeIdentifier)
9797
.WithWorkingDirectory(targetDirectory)
98-
.Execute()
98+
.Execute("/bl:{}")
9999
.Should().Pass();
100100
}
101101

@@ -130,7 +130,7 @@ public void RemovePackageFromGlobalPackages(ITestOutputHelper log, string packag
130130
if (Directory.Exists(packagePathInGlobalPackages))
131131
{
132132
Directory.Delete(packagePathInGlobalPackages, true);
133-
}
133+
}
134134
}
135135

136136
/// <summary>

0 commit comments

Comments
 (0)