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

PackageReferences put ref instead of lib assemblies in the BuiltProjectOutputGroupDependencies output group used by VS installer projects #9310

Closed
MSLukeWest opened this issue Mar 16, 2020 · 5 comments
Labels
Resolution:External This issue appears to be External to nuget

Comments

@MSLukeWest
Copy link

NuGet product used: VS UI

NuGet version: 5.6.0.6489

VS version (if appropriate): 16.5

OS version: 19h1

Worked before? If so, with which NuGet version: Never worked with PackageRef, still works with Package.json

Detailed repro steps so we can see the same problem

  1. Create a .NET framework C# console app
  2. Manage Nuget packages, add latest System.ValueTuple (4.5.0)
  3. Right click on packages.config in SE, select "Migrate packages.config to PackageReference …" (Note: No repro if you use packages.config)
  4. Add a setup project that references the primary output of the console app and build (Requires VS extension: https://marketplace.visualstudio.com/items?itemName=visualstudioclient.MicrosoftVisualStudio2017InstallerProjects)
  5. Install the generated msi

Expected: It installs the System.ValueTuple assembly from the “lib” directory
Actual: It installs the assembly from the “ref” directory, causing runtime failures

The output group BuiltProjectOutputGroupDependencies is incorrectly populated when using a package reference to consume nuget packages that have both ref and lib versions of their assemblies. Some inital inspection of the build logs shows that with packages.config the lib version is added to the "Reference" item group, which eventually makes its way into a ReferencePath item, which gets added to BuiltProjectOutputGroupDependencies.

With PackageReference, ResolveNuGetPackageAssets adds:

  • lib to ReferenceCopyLocalPaths
  • ref to Reference

So even though the lib version makes it to the bin folder through ReferenceCopyLocalPaths, the ref version is what gets added to BuiltProjectOutputGroupDependencies.

This has been reported by a few different customers, here’s a link to one of the feedback tickets: https://developercommunity.visualstudio.com/content/problem/810090/visual-studio-installer-projects-extensions-incorr.html. As we mentioned in that ticket, there’s a couple potential workarounds, but neither of them are very reliable.

@yirkha
Copy link

yirkha commented Apr 11, 2020

FYI I think this is not an issue with NuGet but rather the Visual Studio Installer Extensions SDK.

Their MSBuild integration uses BuiltProjectOutputGroupDependencies in a way that should not be done – see this issue for details: dotnet/msbuild#3069

I've provided a workaround in Azure/azure-sdk-for-net#3699 (comment) which might potentially work similarly in this case too.

@MSLukeWest
Copy link
Author

Thanks @yirkha. I'm adding the work around here for easier access. Putting this at the end of your csproj file will get around this issue when using installer projects (requires a restart of VS):

<Target
	Name="BuiltProjectOutputGroupDependencies"
	DependsOnTargets="$(BuiltProjectOutputGroupDependenciesDependsOn)"
	Returns="@(BuiltProjectOutputGroupDependency)">
	<ItemGroup>
		<BuiltProjectOutputGroupDependency Include="@(ReferenceCopyLocalPaths->'%(FullPath)');
                                              @(ReferenceDependencyPaths->'%(FullPath)');
                                              @(NativeReferenceFile->'%(FullPath)');
                                              @(_DeploymentLooseManifestFile->'%(FullPath)');
                                              @(ResolvedIsolatedComModules->'%(FullPath)')"/>
	</ItemGroup>
</Target>

@nkolev92 nkolev92 added the Resolution:External This issue appears to be External to nuget label Jul 2, 2020
@nkolev92
Copy link
Member

nkolev92 commented Jul 2, 2020

Closing as per the previous comments.
This is not something in NuGet Client's control.

@nkolev92 nkolev92 closed this as completed Jul 2, 2020
@xxl-cc
Copy link

xxl-cc commented Dec 1, 2020

i have same problem。

@mbihler
Copy link

mbihler commented Feb 12, 2021

Thanks @yirkha. Your workaround works with my setup project.
But because COM wrapper assemblies were missing in generated msi, I had to add this to the include list:
@(ReferenceComWrappersToCopyLocal->'%(FullPath)')

kzu added a commit to devlooped/nugetizer that referenced this issue Feb 10, 2023
We were previously using a combination of @(ReferencePath) and @(_ReferenceRelatedPaths) to determine the candidate libs to pack as private, but this was incorrect since we would still sometimes pack ref assemblies.

Turns out that this is an issue that surfaced elsewhere (see NuGet/Home#9310 (comment)) which resulted in a new output group being available from the common MSBuild targets (see dotnet/msbuild#3069) that we can use instead to do this properly.

Closes #263
kzu added a commit to devlooped/nugetizer that referenced this issue Feb 10, 2023
We were previously using a combination of @(ReferencePath) and @(_ReferenceRelatedPaths) to determine the candidate libs to pack as private, but this was incorrect since we would still sometimes pack ref assemblies.

Turns out that this is an issue that surfaced elsewhere (see NuGet/Home#9310 (comment)) which resulted in a new output group being available from the common MSBuild targets (see dotnet/msbuild#3069) that we can use instead to do this properly.

Closes #263
kzu added a commit to devlooped/nugetizer that referenced this issue Feb 10, 2023
We were previously using a combination of @(ReferencePath) and @(_ReferenceRelatedPaths) to determine the candidate libs to pack as private, but this was incorrect since we would still sometimes pack ref assemblies.

Turns out that this is an issue that surfaced elsewhere (see NuGet/Home#9310 (comment)) which resulted in a new output group being available from the common MSBuild targets (see dotnet/msbuild#3069) that we can use instead to do this properly.

Closes #263
kzu added a commit to devlooped/nugetizer that referenced this issue Feb 10, 2023
We were previously using a combination of @(ReferencePath) and @(_ReferenceRelatedPaths) to determine the candidate libs to pack as private, but this was incorrect since we would still sometimes pack ref assemblies.

Turns out that this is an issue that surfaced elsewhere (see NuGet/Home#9310 (comment)) which resulted in a new output group being available from the common MSBuild targets (see dotnet/msbuild#3069) that we can use instead to do this properly.

Closes #263
kzu added a commit to devlooped/nugetizer that referenced this issue Feb 10, 2023
We were previously using a combination of @(ReferencePath) and @(_ReferenceRelatedPaths) to determine the candidate libs to pack as private, but this was incorrect since we would still sometimes pack ref assemblies.

Turns out that this is an issue that surfaced elsewhere (see NuGet/Home#9310 (comment)) which resulted in a new output group being available from the common MSBuild targets (see dotnet/msbuild#3069) that we can use instead to do this properly.

Closes #263
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution:External This issue appears to be External to nuget
Projects
None yet
Development

No branches or pull requests

6 participants