Skip to content

Commit 42c31c5

Browse files
committed
Use csproj as pack input instead of nuspec
Now that sourcelink is a native part of the .NET SDK, Arcade doesn't bring sourcelink packages in anymore. Now that the cyclic package dependency is avoided, these projects don't need to use nuspecs anymore. This removes custom infrastructure and allows better source build controls. I diffed the produced packages and the content in the .NETCoreApp folder is identical (a deps.json file is added but that's recommended by msbuild for build tasks these days). The .NET Framework output is significantly different as it now includes all dependencies that aren't supplied by the MSBuild inside Visual Studio.
1 parent ed56d42 commit 42c31c5

63 files changed

Lines changed: 249 additions & 420 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eng/BuildTask.targets

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<Project>
2+
3+
<PropertyGroup>
4+
<IncludeBuildOutput>false</IncludeBuildOutput>
5+
<IsPackable>true</IsPackable>
6+
<!-- Build Tasks should have this set per https://github.com/dotnet/arcade/blob/main/Documentation/CorePackages/Versioning.md#recommended-settings -->
7+
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>
8+
<BuildTaskTargetFolder>tools</BuildTaskTargetFolder>
9+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);_AddBuildOutputToPackageCore;_AddBuildOutputToPackageDesktop</TargetsForTfmSpecificContentInPackage>
10+
<DevelopmentDependency>true</DevelopmentDependency>
11+
<!-- Some target frameworks declared in the dependencies group of the nuspec and the lib/ref folder do not have exact matches in the other location. -->
12+
<NoWarn>$(NoWarn);NU5128</NoWarn>
13+
</PropertyGroup>
14+
15+
<!--
16+
Default to including all *.props and *.targets files
17+
from the project directory into the NuGet package root
18+
-->
19+
<ItemGroup Condition="'$(EnableDefaultItems)' != 'false'">
20+
<None Condition="'$(EnableDefaultNoneItems)' != 'false'"
21+
Include="**/*.props;**/*.targets"
22+
Pack="true"
23+
PackagePath="%(RecursiveDir)%(Filename)%(Extension)" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<None Include="$(RepoRoot)License.txt" PackagePath="LICENSE.txt" Pack="true"/>
28+
</ItemGroup>
29+
30+
<!-- Exclude assemblies that MSBuild ships with. -->
31+
<ItemGroup>
32+
<PackageReference Update="Microsoft.Build" Publish="false" PrivateAssets="all" />
33+
<PackageReference Update="Microsoft.Build.Framework" Publish="false" PrivateAssets="all" />
34+
<PackageReference Update="Microsoft.Build.Tasks.Core" Publish="false" PrivateAssets="all" />
35+
<PackageReference Update="Microsoft.Build.Utilities.Core" Publish="false" PrivateAssets="all" />
36+
<PackageReference Update="Microsoft.NET.StringTools" Publish="false" PrivateAssets="all" />
37+
<PackageReference Update="System.Collections.Immutable" Publish="false" PrivateAssets="all" />
38+
</ItemGroup>
39+
40+
<!-- Exclude assemblies that are already provided by the SDK, next to MSBuild. -->
41+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
42+
<PackageReference Update="Newtonsoft.Json" Publish="false" PrivateAssets="all" />
43+
<PackageReference Update="NuGet.Commands" Publish="false" PrivateAssets="all" />
44+
<PackageReference Update="NuGet.Common" Publish="false" PrivateAssets="all" />
45+
<PackageReference Update="NuGet.Configuration" Publish="false" PrivateAssets="all" />
46+
<PackageReference Update="NuGet.Frameworks" Publish="false" PrivateAssets="all" />
47+
<PackageReference Update="NuGet.Packaging" Publish="false" PrivateAssets="all" />
48+
<PackageReference Update="NuGet.ProjectModel" Publish="false" PrivateAssets="all" />
49+
<PackageReference Update="NuGet.Versioning" Publish="false" PrivateAssets="all" />
50+
</ItemGroup>
51+
52+
<!-- Don't include assemblies that are inbox in Desktop MSBuild -->
53+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
54+
<PackageReference Update="System.Buffers" Publish="false" PrivateAssets="all" />
55+
<PackageReference Update="System.Memory" Publish="false" PrivateAssets="all" />
56+
<PackageReference Update="System.Numerics.Vectors" Publish="false" PrivateAssets="all" />
57+
<PackageReference Update="System.Reflection.Metadata" Publish="false" PrivateAssets="all" />
58+
<PackageReference Update="System.Reflection.MetadataLoadContext" Publish="false" PrivateAssets="all" />
59+
<PackageReference Update="System.Runtime.CompilerServices.Unsafe" Publish="false" PrivateAssets="all" />
60+
<PackageReference Update="System.Text.Encodings.Web" Publish="false" PrivateAssets="all" />
61+
<PackageReference Update="System.Text.Json" Publish="false" PrivateAssets="all" />
62+
<PackageReference Update="System.Threading.Tasks.Dataflow" Publish="false" PrivateAssets="all" />
63+
<PackageReference Update="System.Threading.Tasks.Extensions" Publish="false" PrivateAssets="all" />
64+
<PackageReference Update="System.ValueTuple" Publish="false" PrivateAssets="all" />
65+
</ItemGroup>
66+
67+
<ItemGroup>
68+
<!--
69+
Update all PackageReference and ProjectReference items to default Publish to true.
70+
This forces the publish output to contain the dlls.
71+
-->
72+
<PackageReference Update="@(PackageReference)">
73+
<Publish Condition="'%(PackageReference.Publish)' == ''">true</Publish>
74+
<ExcludeAssets Condition="'%(PackageReference.Publish)' == 'false'">runtime</ExcludeAssets>
75+
</PackageReference>
76+
<ProjectReference Update="@(ProjectReference)">
77+
<Publish Condition="'%(ProjectReference.Publish)' == ''">true</Publish>
78+
<Private Condition="'%(ProjectReference.Publish)' == 'false'">false</Private>
79+
</ProjectReference>
80+
</ItemGroup>
81+
82+
<!-- Publish .NET Core assets and include them in the package under $(BuildTaskTargetFolder) directory. -->
83+
<Target Name="_AddBuildOutputToPackageCore" DependsOnTargets="Publish" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
84+
<ItemGroup>
85+
<TfmSpecificPackageFile Include="$(PublishDir)**"
86+
PackagePath="$(BuildTaskTargetFolder)/$(TargetFramework)/%(RecursiveDir)%(FileName)%(Extension)"/>
87+
</ItemGroup>
88+
</Target>
89+
90+
<!-- Include .NET Framework build outputs in the package under $(BuildTaskTargetFolder) directory. -->
91+
<Target Name="_AddBuildOutputToPackageDesktop" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
92+
<ItemGroup>
93+
<TfmSpecificPackageFile Include="$(OutputPath)**" PackagePath="$(BuildTaskTargetFolder)/$(TargetFramework)/%(RecursiveDir)%(FileName)%(Extension)"/>
94+
</ItemGroup>
95+
</Target>
96+
97+
</Project>

src/Directory.Build.props

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,5 @@
99

1010
<IncludeSymbols Condition="'$(DebugType)' != 'embedded' and '$(UsingMicrosoftNoTargetsSdk)' != 'true'">true</IncludeSymbols>
1111
</PropertyGroup>
12-
13-
<!--
14-
Workaround for https://github.com/dotnet/sdk/issues/2232: GenerateDepsFile throws ArgumentException.
15-
-->
16-
<PropertyGroup Condition="'$(IsTestProject)' != 'true'">
17-
<GenerateDependencyFile>false</GenerateDependencyFile>
18-
</PropertyGroup>
12+
1913
</Project>

src/Directory.Build.targets

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,19 @@
33

44
<!-- TODO: Remove when Arcade offers an in-built way to filter out anything other than NetCurrent: https://github.com/dotnet/arcade/issues/13390. -->
55
<PropertyGroup>
6-
<TargetFrameworks Condition="'$(TargetFrameworks)' != '' and '$(DotNetBuildFromSource)' == 'true'">$(NetCurrent)</TargetFrameworks>
6+
<TargetFrameworks Condition="'$(TargetFrameworks)' != '' and '$(DotNetBuildFromSource)' == 'true'">$(NetToolCurrent)</TargetFrameworks>
77
</PropertyGroup>
88

99
<ItemGroup Condition="'$(IsTestProject)' == 'true'">
1010
<!-- Upgrade the NETStandard.Library transitive xunit dependency to avoid transitive 1.x NS dependencies. -->
1111
<PackageReference Include="NETStandard.Library" Version="2.0.3" Condition="'$(TargetFrameworkIdentifier)' != '.NETStandard'" />
1212
</ItemGroup>
1313

14-
<ItemGroup>
15-
<NuspecProperty Include="DesktopTfm=net472"/>
16-
<NuspecProperty Include="CoreTfm=$(NetCurrent)" Condition="'$(DotNetBuildFromSource)' == 'true'"/>
17-
<NuspecProperty Include="CoreTfm=$(NetMinimum)" Condition="'$(DotNetBuildFromSource)' != 'true'"/>
18-
</ItemGroup>
19-
20-
<!--
21-
Workaround for https://github.com/NuGet/Home/issues/6754: cyclic dependency.
22-
-->
23-
<PropertyGroup>
24-
<_ProjectDefinedPackageId>$(PackageId)</_ProjectDefinedPackageId>
25-
<PackageId>*fake_packageid_for_project_$(MSBuildProjectName)*</PackageId>
26-
</PropertyGroup>
27-
2814
<!--
2915
Workaround for https://github.com/Microsoft/msbuild/issues/2527.
3016
-->
3117
<PropertyGroup>
3218
<ImplicitlyExpandNETStandardFacades Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">false</ImplicitlyExpandNETStandardFacades>
3319
</PropertyGroup>
3420

35-
<!--
36-
Workaround for cyclic package reference. PackageId is set to ain invalid value above (in evaluation phase to be picked up by Restore),
37-
then updated to the actual value before Pack target and SourceLink source package generation target.
38-
-->
39-
<Target Name="_UpdatePackageId" BeforeTargets="$(PackDependsOn);InitializeSourceControlInformation" >
40-
<PropertyGroup>
41-
<PackageId>$(_ProjectDefinedPackageId)</PackageId>
42-
<PackageId Condition="'$(PackageId)' == ''">$(AssemblyName)</PackageId>
43-
<PackageId Condition="'$(PackageId)' == ''">$(MSBuildProjectName)</PackageId>
44-
</PropertyGroup>
45-
</Target>
4621
</Project>

src/Microsoft.Build.StandardCI/Microsoft.Build.StandardCI.csproj

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,11 @@
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5-
<IsPackable>true</IsPackable>
65
<SuppressFinalPackageVersion>true</SuppressFinalPackageVersion>
76
<PackageDescription>Standard CI targets.</PackageDescription>
87
<PackageTags>Standard CI msbuild targets</PackageTags>
9-
<DevelopmentDependency>true</DevelopmentDependency>
10-
<!-- This is a content only package. -->
11-
<NoWarn>$(NoWarn);NU5128</NoWarn>
12-
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
138
</PropertyGroup>
149

15-
<ItemGroup>
16-
<None Include="build\Microsoft.Build.StandardCI.props"
17-
Pack="true"
18-
PackagePath="build" />
19-
</ItemGroup>
10+
<Import Project="$(RepositoryEngineeringDir)BuildTask.targets" />
2011

2112
</Project>

src/Microsoft.Build.StandardCI/Microsoft.Build.StandardCI.nuspec

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the License.txt file in the project root for more information. -->
2+
<Project>
3+
<Import Project="..\build\$(MSBuildThisFileName).props"/>
4+
</Project>

src/Microsoft.Build.Tasks.Git.UnitTests/Microsoft.Build.Tasks.Git.UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net472;$(NetCurrent)</TargetFrameworks>
4+
<TargetFrameworks>$(NetToolCurrent);$(NetFrameworkToolCurrent)</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net472;$(NetMinimum);$(NetCurrent)</TargetFrameworks>
4-
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>
5-
6-
<!-- NuGet: Using an explicit nuspec file to customize TFM directory -->
7-
<IsPackable>true</IsPackable>
8-
<NuspecFile>$(MSBuildProjectName).nuspec</NuspecFile>
9-
<NuspecBasePath>$(OutputPath)</NuspecBasePath>
10-
3+
<TargetFrameworks>$(NetToolCurrent);$(NetToolMinimum);$(NetFrameworkToolCurrent)</TargetFrameworks>
114
<PackageDescription>MSBuild tasks providing git repository information.</PackageDescription>
125
<PackageTags>MSBuild Tasks source control git</PackageTags>
13-
<DevelopmentDependency>true</DevelopmentDependency>
14-
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
156
</PropertyGroup>
167
<ItemGroup>
178
<PackageReference Include="Microsoft.Build" Version="$(MicrosoftBuildVersion)" />
@@ -29,4 +20,6 @@
2920
<InternalsVisibleTo Include="Microsoft.Build.Tasks.Git.UnitTests" />
3021
<InternalsVisibleTo Include="Microsoft.SourceLink.Git.IntegrationTests" />
3122
</ItemGroup>
23+
24+
<Import Project="$(RepositoryEngineeringDir)BuildTask.targets" />
3225
</Project>

src/Microsoft.Build.Tasks.Git/Microsoft.Build.Tasks.Git.nuspec

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/Microsoft.Build.Tasks.Git/build/Microsoft.Build.Tasks.Git.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<Project>
33
<PropertyGroup>
44
<MicrosoftBuildTasksGitAssemblyFile Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tools\net472\Microsoft.Build.Tasks.Git.dll</MicrosoftBuildTasksGitAssemblyFile>
5-
<MicrosoftBuildTasksGitAssemblyFile Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tools\core\Microsoft.Build.Tasks.Git.dll</MicrosoftBuildTasksGitAssemblyFile>
5+
<MicrosoftBuildTasksGitAssemblyFile Condition="'$(MSBuildRuntimeType)' == 'Core' and '$(MSBuildVersion)' &lt; '17.8.0'">$(MSBuildThisFileDirectory)..\tools\net6.0\Microsoft.Build.Tasks.Git.dll</MicrosoftBuildTasksGitAssemblyFile>
6+
<MicrosoftBuildTasksGitAssemblyFile Condition="'$(MSBuildRuntimeType)' == 'Core' and '$(MSBuildVersion)' &gt;= '17.8.0'">$(MSBuildThisFileDirectory)..\tools\net8.0\Microsoft.Build.Tasks.Git.dll</MicrosoftBuildTasksGitAssemblyFile>
67
</PropertyGroup>
78
</Project>

0 commit comments

Comments
 (0)