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
Pack includes content brought in through dependency packages into the current project's package (SDK based projects only) #8867
Comments
I'm not exactly following your goal, here. You want the first consumer of your package to see the content (data.json), but anyone who consumes that new package should not see the content of data.json? This MSBuild reference shows examples of how the folder structures work for Content Files: https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#including-content-in-a-package |
Exactly, I do not want to include this file transitively. |
Both |
The short explanation:
The long explanation:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\Documents\Code\Test\8867\gpf</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\Nikolche\Documents\Code\Test\8867\gpf;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.4.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Content Include="$(NuGetPackageRoot)\basepackage\1.0.0\contentFiles\any\any\data.json" Condition="Exists('$(NuGetPackageRoot)\basepackage\1.0.0\contentFiles\any\any\data.json')">
<NuGetPackageId>BasePackage</NuGetPackageId>
<NuGetPackageVersion>1.0.0</NuGetPackageVersion>
<NuGetItemType>Content</NuGetItemType>
<Private>False</Private>
<Link>data.json</Link>
</Content>
</ItemGroup>
</Project> Note the conditional inclusion. So the technical fix here is:
Workaround: As far as workarounds by the time this gets fixed go, unfortunately I can only think of the big hammer. Set |
@nkolev92 Thanks for the detailed answer. I guessed that it could be a bug. But I did not understand this comment:
Did you mean set
Could you say something about when this will be fixed? In the near future is this real? |
Yes, I meant to write that.
Not sure at this point. We have lots of issue that we prioritize based on many factors. |
Thanks.
Yes, I looked at the current list of bugs and guessed that there was enough work there even without my problem.
Unfortunately, this is not an area where I can effectively help. Actually your advice to use |
One more note. Warning if you use
After you use
So you are locked to use |
Duplicate of #8867. |
Wow! I didn't even notice. |
Good catch! |
Meant to say duplicate of #6138 :) |
Reopening since this is a bug in PackageReference project. Related bug applies to packages.config projects. |
Details about Problem
NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): VS 2019
NuGet version (x.x.x.xxx):
dotnet.exe --version (if appropriate): 3.0.100
VS version (if appropriate): 16.3.8
OS version (i.e. win10 v1607 (14393.321)): Windows 10.0.14393 x64
Worked before? If so, with which NuGet version: -
Detailed repro steps so we can see the same problem
I have been using the
PrivateAssets="all"
option for a long time. It works great forPackageReference
. Now I needed to use some content file in my project and I could not achieve the desired behavior withPrivateAssets="all"
. I want to build "base" package with one filedata.json
which should be consumed in "top" package but should not be exposed further to consumers of the "top" package.My "base" package:
The result seems to be good for me:
My "top" package:
The Result is unexpected for me:
Why is the file again in the content section? This file is a development dependency, some sort of settings file. The "base" package is a package with Roslyn analyzers and the settings file -
data.json
. I do not present the analyzers used for clarity. For them,PrivateAssets
works as it should - they do not fall into the dependencies of the "base" package. But for the settings file -data.json
, I can’t get the same behavior.I spent a lot of time resolving this issue and it seems to me that I do not see any obvious solution, which is somewhere nearby. I will be very grateful for the advice.
The text was updated successfully, but these errors were encountered: