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

contentFiles is being ignored by non core projects #7672

Closed
TrabacchinLuigi opened this issue Jan 4, 2019 · 9 comments
Closed

contentFiles is being ignored by non core projects #7672

TrabacchinLuigi opened this issue Jan 4, 2019 · 9 comments
Labels
Area:ContentFiles PackageReference contentFiles folder WaitingForCustomer Applied when a NuGet triage person needs more info from the OP

Comments

@TrabacchinLuigi
Copy link

TrabacchinLuigi commented Jan 4, 2019

I've created a very simple package that is supposed to contain some tooling for the build it just contains an .exe and a .dll into contentFiles\any\any\tools

It works fine when installed in .net core projects, but it doesn't when installed in .net472 projects.
I've done some testings and installing it in projects with packages.config instead of packageReferences doesn't seem to make any difference.

Also changing ..\any\any.. to ..\cs\net472.. or a combination of any, cs and net472 doesn't seem to solve the problem.

I've installed the package via visual studio 2017 GUI. I can't determine the version of the embedded nugget client, but Vs is fully updated.

I also have the last nuget.exe but I still have to try to install using it... I just made the packet with it.

@PatoBeltran
Copy link

hey @TrabacchinLuigi, ContentFiles only works for PackageReference projects (it doesn't work in packages.config), are you installing the package with PackageReference in the net472 project?

You can read more about it here: https://blog.nuget.org/20160126/nuget-contentFiles-demystified.html

@PatoBeltran PatoBeltran added Area:ContentFiles PackageReference contentFiles folder WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Jan 5, 2019
@TrabacchinLuigi
Copy link
Author

TrabacchinLuigi commented Jan 5, 2019

Yes I know, we moved from packages.config to packageReferences few days ago, and noticed our packet was not adding the needed files anymore, so I decided to read about and discovered that the the new way of doing was this cool new node contentFiles... I tried also to keep the old content folder, and then dropped it because I saw no differences, and I read it was only for backward compatibility...

Since I wasn't able to make it work, just for testing I've installed the same updated package in other projects the only one that worked was .net core projects

@TrabacchinLuigi
Copy link
Author

this is how the package looks like:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>SilentWave.Setup.Packer</id>
    <version>1.0.12</version>
    <authors>SilentWave</authors>
    <description>The utility to create the resources for a setup based on SilentWave setup engine.</description>
    <dependencies>
      <dependency id="SilentWave.Setup.Engine" version="1.0.13" />
    </dependencies>
    <contentFiles>
      <files include="**/*" buildAction="None" copyToOutput="true"/>
    </contentFiles>
  </metadata>
  <files>
    <!--<file src="*.*" exclude="*.*" />-->
    <file src="bin\$configuration$\*.exe" target="contentFiles\any\any\Packer" />
    <file src="bin\$configuration$\*.dll" target="contentFiles\any\any\Packer" />
  </files>
</package>

image

and this is how it's referenced:

<ItemGroup>
    <PackageReference Include="Newtonsoft.Json">
      <Version>12.0.1</Version>
    </PackageReference>
    <PackageReference Include="SilentWave.Setup.Engine">
      <Version>1.0.13</Version>
    </PackageReference>
    <PackageReference Include="SilentWave.Setup.Packer">
      <Version>1.0.13</Version>
    </PackageReference>
  </ItemGroup>

image

@TrabacchinLuigi TrabacchinLuigi changed the title ContentFolder is being ignored by .net472 projects ContentFolder is being ignored by non core projects projects Jan 5, 2019
@TrabacchinLuigi
Copy link
Author

I've tried also on .net4.6.1 projects, still doesn't work
i've tried with visual studio 2019 fully updated, still no luck

@TrabacchinLuigi TrabacchinLuigi changed the title ContentFolder is being ignored by non core projects projects ContentFolder is being ignored by non core projects Jan 5, 2019
@TrabacchinLuigi TrabacchinLuigi changed the title ContentFolder is being ignored by non core projects contentFiles is being ignored by non core projects Jan 5, 2019
@TrabacchinLuigi
Copy link
Author

TrabacchinLuigi commented Jan 8, 2019

I've tried also to create a package with some source code placed into contentFiles\cs\any\$id$, the weirdness increment: the files does not show up in the solution, the IDE let you use the types defined in the invisible linked files, but if you use them it won't let you compile anymore, if you don't use them it will compile them successfully, and you can find them in the produced assembly with a decompiler.

@jainaashish
Copy link
Contributor

@TrabacchinLuigi what you means content files are being ignored in net472 project? how are you validating it? Have you build your project and checked into /bin folder if those content files are present there or not?

These content files wont be visible in solution explorer or anything, but they should be available to be consumed by the project and when you build, they should be copied into output folder since you set copyToOutput to true. If this is not happening, please provide a sample repro solution/project along with your sample package which depict the issue.

@TrabacchinLuigi
Copy link
Author

As i said those are tools that make building possible, won't have much sense to have them available after building, but since this is not the only issue i'll provide some examples (not now, it's 2AM here).
Also i'd expect nuget to work the same in every scenario, if i add the package to a .net core project the files are visible from the solution explorer, they appear as linked files and folders.

Another super disappointing detail about the new PackageReference method is that you can't embed those references but this is another topic...

@nkolev92
Copy link
Member

The issue about the content files being displayed is not NuGet's to solve.

You can track is at our partner team's repo. dotnet/project-system#3431

Any repros you can provide?
If you need it to do something at build time, content files might not be the best approach.
You'd probably need a targets file that invokes the exe there.

@TrabacchinLuigi
Copy link
Author

sorry i have no time to make a repro, but i've understood that putting "build pipeline" into nuget packages isn't a good idea, and that mostly it was a visualization problem, i'll track the other issue and close this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:ContentFiles PackageReference contentFiles folder WaitingForCustomer Applied when a NuGet triage person needs more info from the OP
Projects
None yet
Development

No branches or pull requests

4 participants