0

I am creating a NuGet package from a web project (.Net) using VS2017 and _CreateNewNuGetPackage. All the files are put in the /content folder. The problem when installing the NuGet package in a project, is that all the files will be installed in the root folder.

What I really want is to have a Nuget package where all the build files are in content/extraFolder/.

I tried using the tag options in the .nuspec file, but .nuspec adds files from the project and not the build files.

After that i tried setting the build path to bin\extraFolder and using the option "Nuget pack xxx -BasePath ..\ xxx", but it looks like nuget uses the vbproj file and ignores the basepath option.

I know it is possible to nuget install -outputdir extraFolder/ but i would like to make it easy for the users of the nuget package.

The nuget package I want is something like:

content/
  extraFolder/
    all build folders and files
lib/
  dll file

The only thing missing right now is the extraFolder. Does anybody know how i can accomplish this?

1 Answers1

0

What I really want is to have a Nuget package where all the build files are in content/extraFolder/.

If I understand you correctly, you can try to change the target="content" in the .nuspec file to target="content\content\extraFolder". So your .nuspec looks like:

<?xml version="1.0"?>
<package >
  <metadata>
    <id>MyTestPackager</id>
    <version>1.0.0</version>
    <authors>Tester</authors>
    <owners>Tester</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Package description</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2018</copyright>
    <tags>Tag1 Tag2</tags>
  </metadata>
  <files>
    <file src="Test.xml" target="content\content\extraFolder\Test.xml" />
  </files>
</package>

Then when you pack this .nuspec file, you will got the following package:

enter image description here

Add this package to the project, all the build files are in content/extraFolder/:

enter image description here

If I am not understand your question correct, please add to screenshot about your current status and what you want directly.

Update:

The part i do not know anything about is the part where MSBuild puts the builded files in the 'bin' folder

If you want put those files in the \bin folder, you need add a .target file in the \build folder to copy those files to the bin folder:

The content of the .targets file:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
 <ItemGroup>
  <None Include="$(ProjectDir)content\extraFolder\test.txt">
     <Link>test.txt</Link>
     <CopyToOutputDirectory>Always</CopyToOutputDirectory>
  </None>
 </ItemGroup>
</Project>

In the nuspec file, add the .targets file to the build folder:

Check the similar thread for more details.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • I know this part, but then i can only do this with unbuild files. The part i do not know anything about is the part where MSBuild puts the builded files in the 'bin' folder and where _CreateNewNuGetPackage puts those files in the content folder. Somewhere in this automatic process I need to add the extraFolder, because the web files are removed afterwards and only the nupkg and dll files remain in the bin folder. – Frits Becker Aug 20 '18 at 17:55
  • @FritsBecker, Check if the the updated answer useful? – Leo Liu Aug 21 '18 at 01:39
  • @FritsBecker, Any update for this issue? Have you resolved this issue? – Leo Liu Aug 22 '18 at 03:18
  • Thank you for finding this out :) – Frits Becker Aug 23 '18 at 23:39