Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use csproj as pack input instead of nuspec #1119

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Oct 27, 2023

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 hacks, and allows better source build controls.

I diffed the produced packages and the content is identical (a deps.json file is added but that's recommended by msbuild for build tasks these days).

@KalleOlaviNiemitalo
Copy link

Does the team intend to keep publishing sourcelink NuGet packages for use with older SDKs?

@ViktorHofer
Copy link
Member Author

ViktorHofer commented Oct 27, 2023

Does the team intend to keep publishing sourcelink NuGet packages for use with older SDKs?

I'm not the owner of sourcelink but AFAIK yes and this PR doesn't change that. The .NET 9 source link packages will work on all the officially supported MSBuild flavours and supported runtimes.

@ViktorHofer
Copy link
Member Author

Unfortunately I can't reproduce the failures locally: Microsoft.SourceLink.Git.IntegrationTests.

ViktorHofer added a commit to dotnet/arcade that referenced this pull request Oct 31, 2023
@ViktorHofer ViktorHofer force-pushed the UsePackTaskInsteadOfNuspec branch 2 times, most recently from c575a10 to 42c31c5 Compare November 2, 2023 09:10
@ViktorHofer
Copy link
Member Author

cc @tmat

@jaredpar
Copy link
Member

jaredpar commented Nov 2, 2023

@davidwengier can you take a look at this?

Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid including the TFM in the tools package path. It makes things unnecessarily complicated.

@ViktorHofer ViktorHofer force-pushed the UsePackTaskInsteadOfNuspec branch 12 times, most recently from a8489fb to 481ba16 Compare February 1, 2024 15:09
@ViktorHofer ViktorHofer requested a review from tmat February 1, 2024 15:19
@ViktorHofer
Copy link
Member Author

I finally found time to continue to work on this. @tmat, please take a look. I used the same approach that we came up with in arcade for build task projects. Btw, it would be good to switch this repository to Central Package Management with a future change.

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.
@tmat
Copy link
Member

tmat commented Feb 2, 2024

The .NET Framework output is significantly different as it now includes all dependencies that aren't supplied by the MSBuild inside Visual Studio.

Would you mind listing the differences?

eng/BuildTask.targets Outdated Show resolved Hide resolved
@@ -0,0 +1,4 @@
<!-- 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. -->
<Project>
<Import Project="..\build\$(MSBuildThisFileName).props"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import

Why do we need buildTransitive? Seems like a project that depends on a project that has Source Link may or may not opt-into having Source Link. Either way it should work as there is no cross-project dependency on source link.

Copy link
Member Author

@ViktorHofer ViktorHofer Feb 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buildTransitive is necessary so when a package references Microsoft.Build.Tasks.Git.nupkg, the end consumer then receives the msbuild props and targets files from it transitively. That's necessary when using NuGet's Pack task as it emits a slightly different nuspec in regards to IncludeAssets as the current ones.

NuGet/Home#6091 has all the details.

@ViktorHofer
Copy link
Member Author

Would you mind listing the differences?

Sure. I will post the nuspec diffs next week.

README.md Outdated Show resolved Hide resolved
@ViktorHofer
Copy link
Member Author

ViktorHofer commented Aug 20, 2024

@tmat now I really finally got to finishing this PR.

I just diffed the package contents before and after this change and noticed a bug that resulted in assemblies being copied into the package layout unnecessarily. This is now fixed and the diff doesn't show any unexpected changes. The expected ones are:

  • net472 folder name -> netframework, core folder name -> net with the corresponding .props/.targets changes
  • The nuspec now lists dependencies per TFM (that's the default behavior when using the NuGet pack task). Aside from a more verbose listing, this doesn't harm.
  • The License.TXT file is now included (arcade setting)
  • The build task assemblies now include their .deps.json / .config files. That's expected and the msbuild team recommends shipping those along an msbuild package.
  • My local commit is different

Example files diff:

image

(Ignore the package, _rels folder and the ContentType.xml file -> those are things that NuGet creates automatically)

Example nuspec diff:

image

@ViktorHofer ViktorHofer requested a review from tmat August 20, 2024 15:48
@ViktorHofer
Copy link
Member Author

@tmat when you are back from holiday, please take a look. Thanks in advance.

@ViktorHofer
Copy link
Member Author

@tmat gentle ping

@@ -0,0 +1,112 @@
<!-- Copied from arcade with small modifications. -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd be nice to share this rather than making a copy.

@@ -1,19 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do want this project to compile the source. This is to validate that the source package code is correct and builds against the listed TFMs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants