none
What does it mean "put nuspec file into your output folder with the correct format" ? RRS feed

  • Question

  • I have developed a NuGet package to consume in my Universal Windows Platform apps.  I followed this documentation. I first created a new/empty Windows Runtime Component (Universal Windows), then added a class library project (Universal Windows) to that. Then created a nuspec file, with nuget spec command. Then added required dependecies and files like below.   

    <metadata> <!--some-->

    <dependencies> <group targetFramework="UAP10.0"> <dependency id="Microsoft.NETCore.UniversalWindowsPlatform" version="6.2.10" exclude="Build,Analyzers" /> <dependency id="Newtonsoft.Json" version="8.0.3" exclude="Build,Analyzers" /> </group> </dependencies> </metadata> <files> <file src="bin\Release\*" target="lib\uap10.0"/> <file src="bin\Release\Shared\*" target="lib\uap10.0\Shared"/> <file src="bin\Release\Shared\Images\*" target="lib\uap10.0\Shared\Images"/> <file src="bin\Release\Shared\Views\*" target="lib\uap10.0\Shared\Views"/> </files>


    However, in a thread answered by CoolDadTx, it is suggested as below.

    In general you shouldn't be putting paths into your nuspec file as it makes it hard to build it. The correct approach is to put your nuspec file into your output folder with the correct format and then run nuget to package it. This allows you to build it in any configuration. But if you must have paths then the Release build is correct, but you can then only run it in Release builds otherwise it'll fail. Also note that you should be including the binary and PDF files as well to allow for debugging. For class libraries you should also strongly consider including the SymbolLink NuGet package in your code so that people can step into your code by pulling the source from Git/Github. But that is a nice to have.

    What does it mean? Where to put my nuspec file? Do you mean bin folder? If so, it contains 6 folders (ARM, ARM64, Debug, Release, x64, x86), Is there any documentation about it? 

    Also, what does it mean Correct format?






    Tuesday, June 30, 2020 5:08 AM

Answers

  • Add a post-build event to copy the nuspec file into your output directory (`bin\$(Configuration)` in this case).

    Example output
       bin\release
           file.dll
           mypackage.nuspec
           \Shared
           \Images
           \Views

    Then modify yuor nuspec file paths to be relative to that.

    <files>
      <file src="*" target="lib\uap10.0"/>
      <file src="Shared\*" target="lib\uap10.0\Shared"/>
      <file src="Shared\Images\*" target="lib\uap10.0\Shared\Images"/>
      <file src="Shared\Views\*" target="lib\uap10.0\Shared\Views"/>
    </files>

    Now you can build in any configuration and run pack to package up the Nuget package. The configuration no longer matters.


    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by Bhadurudeen Tuesday, June 30, 2020 7:22 PM
    Tuesday, June 30, 2020 1:12 PM
    Moderator

All replies

  • Add a post-build event to copy the nuspec file into your output directory (`bin\$(Configuration)` in this case).

    Example output
       bin\release
           file.dll
           mypackage.nuspec
           \Shared
           \Images
           \Views

    Then modify yuor nuspec file paths to be relative to that.

    <files>
      <file src="*" target="lib\uap10.0"/>
      <file src="Shared\*" target="lib\uap10.0\Shared"/>
      <file src="Shared\Images\*" target="lib\uap10.0\Shared\Images"/>
      <file src="Shared\Views\*" target="lib\uap10.0\Shared\Views"/>
    </files>

    Now you can build in any configuration and run pack to package up the Nuget package. The configuration no longer matters.


    Michael Taylor http://www.michaeltaylorp3.net

    • Marked as answer by Bhadurudeen Tuesday, June 30, 2020 7:22 PM
    Tuesday, June 30, 2020 1:12 PM
    Moderator
  • Great idea & wonderful solution to create the nupkg file. You saved my day.

    For the first time, I have created build events.

    Thank you very much.


    Tuesday, June 30, 2020 7:22 PM