2
votes

I'm trying to create a nuget package for a specific build configuration. Let's use Debug as an example. I run the command:

nuget pack path_to_my.nuspec -Properties "Configuration=Debug;"-Verbosity Detailed

It throws me the following error:

Attempting to build package from 'path_to_my.nuspec'. System.IO.FileNotFoundException: File not found: 'bin\Release\mydll.dll'.

As you can see, it tries to get the dll from bin\Release, and not bin\Debug.

Is it possible to tell nuget to use a different Configuration than Release, or use another path?

1
Are you using Windows Powershell? Do you have Co-App tools installed? I ask because I do and when I do a which nuget that nuget executable is older which causes me trouble. What version are you running?A.J.
@matap very interested to know more details of this problem and find a fix that would work for you. Could you please file a bug at github.com/nuget/home/issues and provide all the relevant details (nuget.exe version, the exact command line you are using) along with a repro project if possible? Thanks!rohit21agrawal
can you show your nuspec?diegosasw

1 Answers

2
votes

It would be necessary to check your nuspec file just in case you have hardcoded the Release path to bin\Release\mydll.dll, which is seems it's the case.

A valid nuspec file would have references to the dll without specifying the environment. Use wildcard to allow for any environment. For example:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>MyProject</id>
    <authors>iberodev</authors>
    <version>1.0.0</version>
    <projectUrl>https://www.diegodrivendesign.com/</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Sample</description>
  </metadata>
  <files>
    <file src="bin\*\netstandard2.0/ProjectOne.dll" target="lib\netstandard2.0" />
    <file src="bin\*\netstandard2.0/ProjectOne.pdb" target="lib\netstandard2.0" />
    <file src="bin\*\netstandard2.0/ProjectTwo.pdb" target="lib\netstandard2.0" />
    <file src="bin\*\netstandard2.0/ProjectTwo.pdb" target="lib\netstandard2.0" />
  </files>
</package>

then you run the nuget pack command to reference your nuspec. Make sure you have compiled the code for the proper environment so that the dll that the nuspec references are available (e.g: dotnet build --configuration Debug)

nuget pack ./*NuGet/*.nuspec -Version 1.0.0 -OutputDirectory foo -Prop Configuration=Debug -Verbosity detailed