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

msbuild /t:Restore and Visual Studio produce different assets files when assembly name != project name #8272

Closed
aolszowka opened this issue Jun 28, 2019 · 13 comments · Fixed by NuGet/NuGet.Client#4172 or NuGet/NuGet.Client#4213
Assignees
Labels
Area:RestoreNoOp The PackageReference no-op Category:Quality Week Issues that should be considered for quality week Functionality:Restore Priority:2 Issues for the current backlog. Product:VS.Client Type:Bug

Comments

@aolszowka
Copy link

Environment(s)

  • Visual Studio 2019 16.1.4
  • Visual Studio 2017 15.9.13

Issue

See attached project for a small repo of this.

It appears that when you perform an msbuild /restore the project.assets.json that gets generated uses the AssemblyName of the referenced class Library. However if you open up Visual Studio it will perform a restore setting this to the name of the referenced PROJECT file. This change forces a Visual Studio rebuild. It is especially painful depending on the size of the solution.

Repo Project

NuGetProjectAssetsJsonDiffs.zip

  1. Starting with a clean project perform a msbuild /restore *.sln
  2. Save off the project.asset.json
  3. Open the project in Visual Studio, Notice that it will feel the need to restore the project packages again even though in theory it should have already been restored.
  4. Compare the "new" project.asset.json to see that it is using the name of the project file as opposed to the assembly name.

image

@rrelyea
Copy link
Contributor

rrelyea commented Jun 28, 2019

@nkolev92 @dtivel - known issue?

@nkolev92
Copy link
Member

Not as far as I'm aware.

Related code for the fix:
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Clients/NuGet.PackageManagement.VisualStudio/Projects/LegacyPackageReferenceProject.cs#L332

I'd imagine the references reader is just returning the path.

I'm curious whether this is also an issue with SDK based projects.

@aolszowka
Copy link
Author

@nkolev92 We don't use any SDK Based projects at this time. Beyond that, is there something we can do to assist in debugging?

Thank you

@nkolev92
Copy link
Member

nkolev92 commented Jul 1, 2019

@aolszowka

Thanks, I think we have everything.

I can repro the bug, and I have verified and it does not repro on SDK based projects, only in the classic csproj projects.

@aolszowka
Copy link
Author

We appreciate the transparency of a GitHub bug; is there anything that explains what the various tags mean? "NeedsTriageDiscussion" implies that there will be discussion on where this falls in your priority queue but is that discussion had in a public forum or at certain touch points?

Thank you

@nkolev92
Copy link
Member

@aolszowka

This specific tag is usually used to mark that the team internally needs to have a discussion about the risks to determine the priority for scheduling some time for a specific dev to fix it.

Right now we don't have a community stand-up of the sort, but we're always willing to interact with customers on the issues themselves.

We also don't really have a summary of what all our labels mean.

@rrelyea rrelyea changed the title msbuild /t:Restore and Visual Studio produce different assets files msbuild /t:Restore and Visual Studio produce different assets files when assembly name != project name Jul 10, 2019
@rrelyea rrelyea added Priority:2 Issues for the current backlog. and removed Triage:NeedsTriageDiscussion labels Jul 10, 2019
@rrelyea
Copy link
Contributor

rrelyea commented Jul 10, 2019

Likely broken since VS2015 & project.json and since VS 2017 & packageref. As such, good bug to fix, but first complaint, we think.

@aolszowka
Copy link
Author

@rrelyea Its a particularly subtle bug, I suspect most devs would write it off as happenstance because after the "second build" in Visual Studio it goes away. We only notice it due to the scale of of our product (~1500 C# Files which FORCE us to build via MSBuild THEN open in VS otherwise we OOM Everywhere when trying to build).

On rebuilds it disappears but we also have a number of versions (~9 active versions at any given time) which causes the rebuild from scratch to happen much more often than one would think. Our deep dependency tree has hurt us as well.

@erdembayar
Copy link
Contributor

Now difference is less than 2 years before, but still difference cause already restored solution restore 1 more time due to project.assets.json is different.

Compare1

@erdembayar
Copy link
Contributor

@aolszowka
I created PR to address this bug. Feel free to review it.
NuGet/NuGet.Client#4172

@aolszowka
Copy link
Author

@erdembayar I wanted to say thank you for submitting a fix for this. I no longer work for the company that most directly affected by this, but this is a great win either way!

@madkat I don't think I have Dion on here, but maybe of interest to some of the larger code bases that you guys are familiar with :)

@madkat
Copy link

madkat commented Aug 21, 2021

@aolszowka Thanks for tagging me. I appreciate your effort in getting this tracked down!

@Deezhohn
Copy link

@aolszowka, @madkat Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment