0

While building my C++ application, the postbuild event contains the following command:

NuGet pack "$(ProjectPath)" 
           -OutputDirectory "$(TargetDir)NuGet"
           -IncludeReferencedProjects
           -Properties Configuration=$(ConfigurationName)

First this failed due to error code 9009, meaning it didn't find the program "NuGet.exe". I have downloaded that program on my PC, and now this is the error message I get:

C:\Program Files\Microsoft Visual Studio\2022\Professional>NuGet pack ...
Attempting to build package from '....csproj'.
MSBuild auto-detection: using msbuild version '17.14.23.42201' from 'C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin'.
Packing files from 'C:\...\bin\Debug'.
Using '....ExternalInterface.nuspec' for metadata.
The user name or password is incorrect.

This latter is confirmed by Developer Command Prompt (I get there the same error message).

I have the impression "NuGet.exe" is configured somewhere in order to get username/password from... where?

Here is where I stored "NuGet.exe":

C:\Program Files\NuGet>dir /S /B
C:\Program Files\NuGet\nuget.exe

What can I do now? Should I re-install "NuGet.exe" in some official way?

P.s. by adding detailed verbosity to the "NuGet" command, this is the extra information I get:

The user name or password is incorrect.
System.IO.IOException: The user name or password is incorrect.

   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileSystemEnumerableIterator`1.CommonInit()
   at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
   at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
   at NuGet.Common.PathResolver.PerformWildcardSearch(String basePath, String searchPath, Boolean includeEmptyDirectories, String& normalizedBasePath)
   at NuGet.Packaging.PackageBuilder.ResolveSearchPattern(String basePath, String searchPath, String targetPath, Boolean includeEmptyDirectories)
   at NuGet.Packaging.PackageBuilder.AddFiles(String basePath, String source, String destination, String exclude)
   at NuGet.Packaging.PackageBuilder.PopulateFiles(String basePath, IEnumerable`1 files)
   at NuGet.CommandLine.ProjectFactory.ProcessNuspec(PackageBuilder builder, String basePath)
   at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded, PackageBuilder builder)
   at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
   at NuGet.CommandLine.PackCommand.ExecuteCommand()
   at NuGet.CommandLine.Command.ExecuteCommandAsync()
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args, IEnvironmentVariableReader environmentVariableReader)

P.s.2: hereby the contents of the corresponding .nuspec file:

<?xml version="1.0" encoding="utf-8"?>
<package >
  <metadata>
    <id>$id$</id>
    <version>9.10.1680.1</version>
    <title>$title$</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <icon>Frameworks.png</icon>
    <description>Project description</description>
    <releaseNotes></releaseNotes>
    <copyright>$copyright$</copyright>
    <tags></tags>
    <dependencies>
      <group targetFramework=".NETFramework4.8" />
    </dependencies>
 </metadata>
 <files>
    <file src="\\<FileServer>\Packages\NuGet\icons\" />
  </files>  
</package>

Some thoughts:

  1. By adding "detailed" verbosity, I now know that there is a problem while resolving some path.
  2. It would be very useful to have actual argument values instead of the general function description, as in the following lines:
    2.1. Replace at System.IO.Directory.GetFiles(String path
    2.2. ... by at System.IO.Directory.GetFiles("C:\..."
  3. NuGet Pack /? reveals the -NonInteractive switch. In my opinion this means that NuGet Pack can be used in an interactive way too and this seems to be the default. As a result I expect the question for a username/password. As this question does not appear, I suspect that information to be present in some file, but where? (The .nuspec file seems not to contain any such information and the files, referred to, seem only to be *.ico and *.png files)
5
  • You can try adding -Verbosity detailed argument to make build log more informative. Commented Oct 20 at 9:00
  • @user7860670: thanks for your quick reply. I've added the extra information from the "Verbosity" switch, but it looks like general error message to me. I'll also add the contents of the corresponding .nuspec file, maybe this might shed some light on the situation. Commented Oct 20 at 9:23
  • Hmm, does output stay the same if you switch Current Working Directory to your project folder instead of C:\Program Files\Microsoft Visual Studio\2022\Professional? Commented Oct 20 at 9:27
  • @user7860670: I can confirm that the output stays the same in the Developer Command Prompt. I have also added the following lines to the post-build event and indeed the result stays the same: cd "$(ProjectDir)" and cd (that latter command for verifying the current directory indeed changed into the project directory). Commented Oct 20 at 9:41
  • @user7860670: for your information: the output directory did not exist yet, I created it, but the problem remains. I'll have lunch now and get back on the problem afterwards (I wonder if we can determine the link between the call stack of the error message and the argument of the NuGet Pack command). Commented Oct 20 at 10:00

1 Answer 1

1

The problem is due to the fileserver related setting in the .nuspec file:
By replacing "\\<FileServer>\Packages\NuGet\icons\" by C:\Development\NuGet\Icons (after having copied all image-related files), the problem does not occur anymore.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.