Skip to content

Commit 474ceee

Browse files
authored
Use csproj as pack input instead of nuspec (#1119)
* 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. * Update BuildTask.targets * Revert docs change * Fix package content for build task packages * PR feedback for M.SourceLink.Tools.Package
1 parent b7fa6e7 commit 474ceee

65 files changed

Lines changed: 305 additions & 439 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.

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ The only feature currently supported is mapping of source files to the source re
182182

183183
## Prerequisites for .NET projects
184184

185-
Source Link supports classic .NET Framework projects as well as .NET SDK projects, that is projects that import `Microsoft.NET.Sdk` (e.g. like so: `<Project Sdk="Microsoft.NET.Sdk">`). The project may target any .NET Framework or .NET Core App/Standard version. All PDB formats are supported: Portable, Embedded and Windows PDBs.
185+
Source Link supports classic .NET Framework projects as well as .NET SDK projects, that is projects that import `Microsoft.NET.Sdk` (e.g. like so: `<Project Sdk="Microsoft.NET.Sdk">`). The project may target .NET, .NET Framework or .NET Standard. All PDB formats are supported: Portable, Embedded and Windows PDBs.
186186

187-
[.NET Core SDK 2.1.300](https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300) or newer is required for .NET SDK projects. If building via desktop `msbuild` you'll need version 15.7 or higher.
187+
[.NET 8 SDK](https://www.microsoft.com/net/download/dotnet/8.0) or newer is required for .NET SDK projects. If building via desktop `msbuild` you'll need version 16.0 or higher.
188188

189189
The following features are not available in projects that do not import `Microsoft.NET.Sdk`:
190190
- Automatic inclusion of commit SHA in `AssemblyInformationalVersionAttribute`.
@@ -200,8 +200,6 @@ The VC++ linker supports `/SOURCELINK` [switch](https://docs.microsoft.com/en-us
200200

201201
## Known issues
202202

203-
- `EmbedUntrackedSources` does not work in Visual Basic projects that use .NET SDK: https://github.com/dotnet/sourcelink/issues/193 (fixed in Visual Studio 2019)
204-
- Issue when building WPF projects with `/p:ContinuousIntegrationBuild=true`: https://github.com/dotnet/sourcelink/issues/91
205203
- Issue when building WPF projects with embedding sources on and `BaseIntermediateOutputPath` not a subdirectory of the project directory: https://github.com/dotnet/sourcelink/issues/492
206204

207205
## PDB distributions
@@ -222,20 +220,20 @@ Keep in mind that including PDBs in the .nupkg increases the size of the package
222220

223221
- They do not support Windows PDBs (generated by VC++, or for managed projects that set build property `DebugType` to `full`)
224222
- They require the library to be built by newer C#/VB compiler (Visual Studio 2017 Update 9).
225-
- The consumer of the package also needs Visual Studio 2017 Update 9 debugger.
223+
- The consumer of the package also needs Visual Studio 2017 Update 9 or newer.
226224
- Not supported by [Azure DevOps Artifacts](https://azure.microsoft.com/en-us/services/devops/artifacts) service.
227225

228226
Consider including PDBs in the main package if it is not possible to use .snupkg for the above reasons.
229227
For managed projects, consider switching to Portable PDBs by setting `DebugType` property to `portable`. This is the default for .NET SDK projects, but not classic .NET projects.
230228

231229
## Builds
232230

233-
Pre-release builds are available from Azure DevOps public feed: `https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json` ([browse](https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet8)).
231+
Pre-release builds are available from Azure DevOps public feed: `https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json` ([browse](https://dev.azure.com/dnceng/public/_packaging?_a=feed&feed=dotnet9)).
234232

235233
[![Build Status](https://dnceng.visualstudio.com/public/_apis/build/status/SourceLink%20PR?branchName=main)](https://dnceng.visualstudio.com/public/_build/latest?definitionId=297?branchName=main)
236234

237235
## Experience in Visual Studio
238236

239-
The following screenshot demonstrates debugging a NuGet package referenced by an application, with source automatically downloaded from GitHub and used by Visual Studio 2017.
237+
The following screenshot demonstrates debugging a NuGet package referenced by an application, with source automatically downloaded from GitHub and used by Visual Studio.
240238

241239
![sourcelink-example](https://user-images.githubusercontent.com/2608468/39667937-10d7dabe-5076-11e8-815e-935724b3a783.PNG)

eng/BuildTask.targets

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<!-- Copied from arcade with small modifications. -->
2+
<Project>
3+
4+
<PropertyGroup>
5+
<IncludeBuildOutput>false</IncludeBuildOutput>
6+
<IsPackable>true</IsPackable>
7+
<!-- Build Tasks should have this set per https://github.com/dotnet/arcade/blob/master/Documentation/CorePackages/Versioning.md#recommended-settings -->
8+
<AutoGenerateAssemblyVersion>true</AutoGenerateAssemblyVersion>
9+
<PackTasks Condition="'$(PackTasks)' == ''">true</PackTasks>
10+
<TargetsForTfmSpecificContentInPackage Condition="'$(PackTasks)' == 'true'">$(TargetsForTfmSpecificContentInPackage);_AddBuildOutputToPackageCore;_AddBuildOutputToPackageDesktop</TargetsForTfmSpecificContentInPackage>
11+
<DevelopmentDependency>true</DevelopmentDependency>
12+
<!-- 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. -->
13+
<NoWarn>$(NoWarn);NU5128</NoWarn>
14+
</PropertyGroup>
15+
16+
<!--
17+
Default to including all *.props and *.targets files
18+
from the project directory into the NuGet package root
19+
-->
20+
<ItemGroup Condition="'$(EnableDefaultItems)' != 'false'">
21+
<None Condition="'$(EnableDefaultNoneItems)' != 'false'"
22+
Include="**/*.props;**/*.targets"
23+
Pack="true"
24+
PackagePath="%(RecursiveDir)%(Filename)%(Extension)" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<None Include="$(RepoRoot)License.txt" PackagePath="LICENSE.txt" Pack="true"/>
29+
</ItemGroup>
30+
31+
<!-- Don't include assemblies that MSBuild ships with. -->
32+
<ItemGroup>
33+
<PackageReference Update="Microsoft.Build" Publish="false" />
34+
<PackageReference Update="Microsoft.Build.Framework" Publish="false" />
35+
<PackageReference Update="Microsoft.Build.Tasks.Core" Publish="false" />
36+
<PackageReference Update="Microsoft.Build.Utilities.Core" Publish="false" />
37+
<PackageReference Update="Microsoft.NET.StringTools" Publish="false" />
38+
<PackageReference Update="System.Collections.Immutable" 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>
52+
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.Security.Cryptography.Xml" Publish="false" />
62+
<PackageReference Update="System.Text.Encodings.Web" Publish="false" />
63+
<PackageReference Update="System.Text.Json" Publish="false" />
64+
<PackageReference Update="System.Threading.Tasks.Dataflow" Publish="false" />
65+
<PackageReference Update="System.Threading.Tasks.Extensions" Publish="false" />
66+
<PackageReference Update="System.ValueTuple" Publish="false" />
67+
</ItemGroup>
68+
69+
<ItemGroup>
70+
<!--
71+
Update all PackageReference items to default Publish to true.
72+
This forces the publish output to contain the dlls.
73+
-->
74+
<PackageReference Update="@(PackageReference)">
75+
<Publish Condition="'%(PackageReference.Publish)' == ''">true</Publish>
76+
<PrivateAssets Condition="'%(PackageReference.Publish)' == 'false'">all</PrivateAssets>
77+
<ExcludeAssets Condition="'%(PackageReference.Publish)' == 'false'">runtime</ExcludeAssets>
78+
</PackageReference>
79+
80+
<!--
81+
Update all Reference items to have Pack="false"
82+
This removes the frameworkDependency nodes from the generated nuspec
83+
-->
84+
<Reference Update="@(Reference)"
85+
Pack="false" />
86+
</ItemGroup>
87+
88+
<!-- Desktop MSBuild compatibilty -->
89+
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
90+
<PackageReference Update="System.Text.Json" Version="7.0.1" />
91+
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
92+
<PackageReference Update="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
93+
<PackageReference Update="System.Collections.Immutable" Version="7.0.0" />
94+
<PackageReference Update="System.Reflection.Metadata" Version="7.0.0" />
95+
</ItemGroup>
96+
97+
<!-- Publish .NET assets and include them in the package under tools/net directory. -->
98+
<Target Name="_AddBuildOutputToPackageCore" DependsOnTargets="Publish" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
99+
<ItemGroup>
100+
<TfmSpecificPackageFile Include="$(PublishDir)**"
101+
PackagePath="tools/net/%(RecursiveDir)%(FileName)%(Extension)"/>
102+
</ItemGroup>
103+
</Target>
104+
105+
<!-- Include .NET Framework build outputs in the package under tools/netframework directory. -->
106+
<Target Name="_AddBuildOutputToPackageDesktop" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
107+
<ItemGroup>
108+
<TfmSpecificPackageFile Include="$(OutputPath)**" PackagePath="tools/netframework/%(RecursiveDir)%(FileName)%(Extension)"/>
109+
</ItemGroup>
110+
</Target>
111+
112+
</Project>

src/Directory.Build.props

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<Project>
2+
23
<Import Project="Sdk.props" Sdk="Microsoft.DotNet.Arcade.Sdk" />
34

45
<PropertyGroup>
@@ -9,11 +10,5 @@
910

1011
<IncludeSymbols Condition="'$(DebugType)' != 'embedded' and '$(UsingMicrosoftNoTargetsSdk)' != 'true'">true</IncludeSymbols>
1112
</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>
13+
1914
</Project>

src/Directory.Build.targets

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,7 @@
11
<Project>
22

33
<Import Project="Sdk.targets" Sdk="Microsoft.DotNet.Arcade.Sdk" />
4-
5-
<!-- TODO: Remove when Arcade offers an in-built way to filter out anything other than NetCurrent: https://github.com/dotnet/arcade/issues/13390. -->
6-
<PropertyGroup>
7-
<TargetFrameworks Condition="'$(TargetFrameworks)' != '' and '$(DotNetBuildSourceOnly)' == 'true'">$(NetCurrent)</TargetFrameworks>
8-
</PropertyGroup>
9-
10-
<ItemGroup>
11-
<NuspecProperty Include="DesktopTfm=net472"/>
12-
<NuspecProperty Include="CoreTfm=$(NetCurrent)" Condition="'$(DotNetBuildSourceOnly)' == 'true'"/>
13-
<NuspecProperty Include="CoreTfm=$(NetMinimum)" Condition="'$(DotNetBuildSourceOnly)' != 'true'"/>
14-
</ItemGroup>
15-
16-
<!--
17-
Workaround for https://github.com/NuGet/Home/issues/6754: cyclic dependency.
18-
-->
19-
<PropertyGroup>
20-
<_ProjectDefinedPackageId>$(PackageId)</_ProjectDefinedPackageId>
21-
<PackageId>*fake_packageid_for_project_$(MSBuildProjectName)*</PackageId>
22-
</PropertyGroup>
4+
<Import Project="$(RepositoryEngineeringDir)BuildTask.targets" Condition="'$(IsBuildTaskProject)' == 'true'" />
235

246
<!--
257
Workaround for https://github.com/Microsoft/msbuild/issues/2527.
@@ -28,16 +10,4 @@
2810
<ImplicitlyExpandNETStandardFacades Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">false</ImplicitlyExpandNETStandardFacades>
2911
</PropertyGroup>
3012

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

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

Lines changed: 2 additions & 11 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>
8+
<IsBuildTaskProject>true</IsBuildTaskProject>
9+
<PackTasks>false</PackTasks>
1310
</PropertyGroup>
1411

15-
<ItemGroup>
16-
<None Include="build\Microsoft.Build.StandardCI.props"
17-
Pack="true"
18-
PackagePath="build" />
19-
</ItemGroup>
20-
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: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<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>
102

3+
<PropertyGroup>
4+
<TargetFrameworks>$(NetToolMinimum);$(NetFrameworkToolCurrent)</TargetFrameworks>
115
<PackageDescription>MSBuild tasks providing git repository information.</PackageDescription>
126
<PackageTags>MSBuild Tasks source control git</PackageTags>
13-
<DevelopmentDependency>true</DevelopmentDependency>
14-
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
7+
<IsBuildTaskProject>true</IsBuildTaskProject>
158
</PropertyGroup>
169
<ItemGroup>
1710
<PackageReference Include="Microsoft.Build" />
@@ -25,4 +18,5 @@
2518
<InternalsVisibleTo Include="Microsoft.Build.Tasks.Git.UnitTests" />
2619
<InternalsVisibleTo Include="Microsoft.SourceLink.Git.IntegrationTests" />
2720
</ItemGroup>
21+
2822
</Project>

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

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

0 commit comments

Comments
 (0)