Skip to content

Commit 792c346

Browse files
authored
Don't bundle NuGet assemblies in NETCoreApp tasks (#13546)
* Don't bundle NuGet assemblies in NETCoreApp tasks NuGet assemblies are alread bundled into the SDK and therefore don't need to be included in .NETCoreApp msbuild task packages. They need to be kept on .NET Framework which doesn't bundle NuGet along MSBuild. Also fix a version package references using an incorrect NuGet version property.
1 parent fb6291b commit 792c346

File tree

17 files changed

+95
-38
lines changed

17 files changed

+95
-38
lines changed

eng/BuildTask.targets

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<Project>
2+
23
<PropertyGroup>
34
<IncludeBuildOutput>false</IncludeBuildOutput>
45
<IsPackable>true</IsPackable>
56
<!-- Build Tasks should not include any dependencies -->
67
<SuppressDependenciesWhenPacking Condition="'$(SuppressDependenciesWhenPacking)' == ''">true</SuppressDependenciesWhenPacking>
7-
<PackTasks Condition="'$(PackTasks)' == ''">true</PackTasks>
88
<!-- Build Tasks should have this set per https://github.com/dotnet/arcade/blob/master/Documentation/CorePackages/Versioning.md#recommended-settings -->
99
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>
1010
<BuildTaskTargetFolder Condition="'$(BuildTaskTargetFolder)' == ''">tools</BuildTaskTargetFolder>
11+
<PackTasks Condition="'$(PackTasks)' == ''">true</PackTasks>
12+
<TargetsForTfmSpecificContentInPackage Condition="'$(PackTasks)' == 'true'">$(TargetsForTfmSpecificContentInPackage);_AddBuildOutputToPackageCore;_AddBuildOutputToPackageDesktop</TargetsForTfmSpecificContentInPackage>
1113
</PropertyGroup>
1214

1315
<!--
@@ -26,29 +28,52 @@
2628
<None Include="$(RepoRoot)THIRD-PARTY-NOTICES.txt" PackagePath="THIRD-PARTY-NOTICES.txt" Pack="true"/>
2729
</ItemGroup>
2830

31+
<!-- Don't include assemblies that MSBuild ships with. -->
2932
<ItemGroup>
30-
<!--
31-
Do not include assemblies that MSBuild ships with in the package.
32-
-->
3333
<PackageReference Update="Microsoft.Build" Publish="false" />
3434
<PackageReference Update="Microsoft.Build.Framework" Publish="false" />
3535
<PackageReference Update="Microsoft.Build.Tasks.Core" Publish="false" />
3636
<PackageReference Update="Microsoft.Build.Utilities.Core" Publish="false" />
37+
<PackageReference Update="Microsoft.NET.StringTools" Publish="false" />
3738
<PackageReference Update="System.Collections.Immutable" Publish="false" />
38-
<PackageReference Update="System.Runtime.InteropServices.RuntimeInformation" Publish="false" />
39+
</ItemGroup>
40+
41+
<!-- Don't include assemblies that are provided by the SDK, next to MSBuild. -->
42+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and '$(SkipSDKInboxPublishExcludes)' != 'true'">
43+
<PackageReference Update="Newtonsoft.Json" Publish="false" />
44+
<PackageReference Update="NuGet.Commands" Publish="false" />
45+
<PackageReference Update="NuGet.Common" Publish="false" />
46+
<PackageReference Update="NuGet.Configuration" Publish="false" />
47+
<PackageReference Update="NuGet.Frameworks" Publish="false" />
48+
<PackageReference Update="NuGet.Packaging" Publish="false" />
49+
<PackageReference Update="NuGet.ProjectModel" Publish="false" />
50+
<PackageReference Update="NuGet.Versioning" Publish="false" />
51+
</ItemGroup>
3952

53+
<!-- Don't include assemblies that are inbox in Desktop MSBuild -->
54+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
55+
<PackageReference Update="System.Buffers" Publish="false" />
56+
<PackageReference Update="System.Memory" Publish="false" />
57+
<PackageReference Update="System.Numerics.Vectors" Publish="false" />
58+
<PackageReference Update="System.Reflection.Metadata" Publish="false" />
59+
<PackageReference Update="System.Reflection.MetadataLoadContext" Publish="false" />
60+
<PackageReference Update="System.Runtime.CompilerServices.Unsafe" Publish="false" />
61+
<PackageReference Update="System.Text.Encodings.Web" Publish="false" />
62+
<PackageReference Update="System.Text.Json" Publish="false" />
63+
<PackageReference Update="System.Threading.Tasks.Dataflow" Publish="false" />
64+
<PackageReference Update="System.Threading.Tasks.Extensions" Publish="false" />
65+
<PackageReference Update="System.ValueTuple" Publish="false" />
66+
</ItemGroup>
67+
68+
<ItemGroup>
4069
<!--
41-
Update all PackageReference and ProjectReference Items to
42-
default Publish to true.
70+
Update all PackageReference items to default Publish to true.
4371
This forces the publish output to contain the dlls.
4472
-->
4573
<PackageReference Update="@(PackageReference)">
4674
<Publish Condition="'%(PackageReference.Publish)' == ''">true</Publish>
4775
<ExcludeAssets Condition="'%(PackageReference.Publish)' == 'false'">runtime</ExcludeAssets>
4876
</PackageReference>
49-
<ProjectReference Update="@(ProjectReference)">
50-
<Publish Condition="'%(ProjectReference.Publish)' == ''">true</Publish>
51-
</ProjectReference>
5277

5378
<!--
5479
Update all Reference items to have Pack="false"
@@ -57,23 +82,20 @@
5782
<Reference Update="@(Reference)"
5883
Pack="false" />
5984
</ItemGroup>
60-
61-
<PropertyGroup Condition="'$(PackTasks)' == 'true'">
62-
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddBuildOutputToPackageCore;_AddBuildOutputToPackageDesktop</TargetsForTfmSpecificContentInPackage>
63-
</PropertyGroup>
6485

86+
<!-- Publish .NET Core assets and include them in the package under $(BuildTaskTargetFolder) directory. -->
6587
<Target Name="_AddBuildOutputToPackageCore" DependsOnTargets="Publish" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
6688
<ItemGroup>
67-
<!-- Publish .NET Core assets and include them in the package under $(BuildTaskTargetFolder) directory. -->
6889
<TfmSpecificPackageFile Include="$(PublishDir)**"
6990
PackagePath="$(BuildTaskTargetFolder)/$(TargetFramework)/%(RecursiveDir)%(FileName)%(Extension)"/>
7091
</ItemGroup>
7192
</Target>
7293

94+
<!-- Include .NET Framework build outputs in the package under $(BuildTaskTargetFolder) directory. -->
7395
<Target Name="_AddBuildOutputToPackageDesktop" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
7496
<ItemGroup>
75-
<!-- Include .NET Framework build outputs in the package under $(BuildTaskTargetFolder) directory. -->
7697
<TfmSpecificPackageFile Include="$(OutputPath)**" PackagePath="$(BuildTaskTargetFolder)/$(TargetFramework)/%(RecursiveDir)%(FileName)%(Extension)"/>
7798
</ItemGroup>
7899
</Target>
100+
79101
</Project>

eng/Versions.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
<!-- netstandard -->
3434
<NETStandardLibraryVersion>2.0.3</NETStandardLibraryVersion>
3535
<!-- nuget -->
36+
<NuGetCommandsVersion>6.2.2</NuGetCommandsVersion>
3637
<NuGetFrameworksVersion>6.2.2</NuGetFrameworksVersion>
3738
<NuGetPackagingVersion>6.2.2</NuGetPackagingVersion>
39+
<NuGetProjectModelVersion>6.2.2</NuGetProjectModelVersion>
3840
<NuGetVersioningVersion>6.2.2</NuGetVersioningVersion>
3941
<!-- roslyn -->
4042
<MicrosoftCodeAnalysisCSharpVersion>4.4.0</MicrosoftCodeAnalysisCSharpVersion>
@@ -94,6 +96,7 @@
9496
<MicrosoftIdentityClientVersion>4.53.0</MicrosoftIdentityClientVersion>
9597
<!-- Keep Microsoft.Data.Services.Client package version in sync with Microsoft.Data.OData -->
9698
<MicrosoftDataServicesClientVersion>5.8.4</MicrosoftDataServicesClientVersion>
99+
<MicrosoftDiagnosticsRuntimeVersion>1.0.5</MicrosoftDiagnosticsRuntimeVersion>
97100
<MicrosoftOpenApiReadersVersion>1.3.2</MicrosoftOpenApiReadersVersion>
98101
<MicrosoftOpenApiVersion>1.3.2</MicrosoftOpenApiVersion>
99102
<MicrosoftSignedWixVersion>1.0.0-v3.14.0.5722</MicrosoftSignedWixVersion>

src/Microsoft.DotNet.ApiCompat/src/Microsoft.DotNet.ApiCompat.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>$(NetCurrent);$(NetFrameworkToolCurrent)</TargetFrameworks>
5-
<OutputType>Exe</OutputType>
65
<ExcludeFromSourceBuild>true</ExcludeFromSourceBuild>
76
<IsPackable>true</IsPackable>
87
<NoWarn>$(NoWarn);0436</NoWarn>
98
<RollForward>Major</RollForward>
109
<DefaultExcludesInProjectFolder>Microsoft.DotNet.ApiCompat.Core\**\*</DefaultExcludesInProjectFolder>
10+
<!-- APICompat is used as both a CLI tool and an msbuild task via the same assembly. -->
11+
<OutputType>Exe</OutputType>
12+
<SkipSDKInboxPublishExcludes>true</SkipSDKInboxPublishExcludes>
1113
</PropertyGroup>
1214

1315
<ItemGroup>

src/Microsoft.DotNet.Build.Tasks.Packaging/src/Microsoft.DotNet.Build.Tasks.Packaging.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
<PackageDownload Include="Microsoft.NETCore.Platforms" Version="[$(MicrosoftNETCorePlatformsVersion)]" />
5050
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreVersion)" />
5151
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
52-
<PackageReference Include="NuGet.Commands" Version="$(NuGetPackagingVersion)" />
52+
<PackageReference Include="NuGet.Commands" Version="$(NuGetCommandsVersion)" />
5353
<PackageReference Include="NuGet.Packaging" Version="$(NuGetPackagingVersion)" />
54-
<PackageReference Include="NuGet.ProjectModel" Version="$(NuGetPackagingVersion)" />
54+
<PackageReference Include="NuGet.ProjectModel" Version="$(NuGetProjectModelVersion)" />
5555
</ItemGroup>
5656

5757
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">

src/Microsoft.DotNet.Build.Tasks.Workloads.Tests/Microsoft.DotNet.Build.Tasks.Workloads.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
<PackageReference Include="Microsoft.Signed.Wix" Version="$(MicrosoftSignedWixVersion)" />
1616
</ItemGroup>
1717

18+
<!-- The tests reference the MSBuild task assembly directly and therefore we need to add references that would normally be provided by MSBuild. -->
19+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
20+
<PackageReference Include="NuGet.Packaging" Version="$(NuGetPackagingVersion)" />
21+
</ItemGroup>
22+
1823
<!-- Sample packages -->
1924
<ItemGroup>
2025
<PackageDownload Include="Microsoft.Signed.Wix" Version="[$(MicrosoftSignedWixVersion)]" />

src/Microsoft.DotNet.Deployment.Tasks.Links/Microsoft.DotNet.Deployment.Tasks.Links.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="Microsoft.Identity.Client" Version="$(MicrosoftIdentityClientVersion)" />
14-
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCoreVersion)" Publish="false" ExcludeAssets="runtime" />
14+
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildUtilitiesCoreVersion)" />
1515
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
1616
</ItemGroup>
1717

src/Microsoft.DotNet.GenFacades/Microsoft.DotNet.GenFacades.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreVersion)" Publish="false" />
11-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpVersion)" ExcludeAssets="analyzers" Publish="false" />
10+
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreVersion)" />
11+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpVersion)" />
1212
</ItemGroup>
1313

1414
<ItemGroup>

src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
<PackageReference Include="Moq" Version="$(MoqVersion)" />
1313
</ItemGroup>
1414

15+
<!-- The tests reference the MSBuild task assembly directly and therefore we need to add references that would normally be provided by MSBuild. -->
16+
<ItemGroup>
17+
<PackageReference Include="NuGet.Versioning" Version="$(NuGetVersioningVersion)" />
18+
</ItemGroup>
19+
1520
<ItemGroup>
1621
<ProjectReference Include="..\..\..\Common\Microsoft.Arcade.Common\Microsoft.Arcade.Common.csproj" />
1722
<ProjectReference Include="..\..\..\Common\Microsoft.Arcade.Test.Common\Microsoft.Arcade.Test.Common.csproj" />

src/Microsoft.DotNet.NuGetRepack/tasks/Microsoft.DotNet.NuGetRepack.Tasks.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="NuGet.Versioning" Version="$(NuGetPackagingVersion)" />
1413
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreVersion)" />
14+
<PackageReference Include="NuGet.Versioning" Version="$(NuGetVersioningVersion)" />
1515
</ItemGroup>
1616

1717
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">

src/Microsoft.DotNet.NuGetRepack/tests/Microsoft.DotNet.NuGetRepack.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="NuGet.Versioning" Version="$(NuGetPackagingVersion)" />
9+
<PackageReference Include="NuGet.Versioning" Version="$(NuGetVersioningVersion)" />
1010
<PackageReference Include="Microsoft.Build.Tasks.Core" Version="$(MicrosoftBuildTasksCoreVersion)" />
1111
</ItemGroup>
1212

0 commit comments

Comments
 (0)