2

I'm writing a deploying app to take my DLL's and create .nuspec files for each, package them, and push out to Artifactory.

Trying to use command line in c# to do this.

The problem I'm having is that the DLL's are on a network drive, and calling nuget spec command on the file location uses the full file path as the PackageID which contains invalid characters when trying to pack.

using (Process myProcess = new Process())
{
  var file = @"\\network-drive\Network-Folder\MyDLLs\Test.dll";
  myProcess.StartInfo.UseShellExecute = false;
  myProcess.StartInfo.FileName = "CMD.exe";
  myProcess.StartInfo.Arguments = string.Format("/c nuget spec \"{0}\"", file);
  myProcess.StartInfo.CreateNoWindow = false;
  myProcess.StartInfo.RedirectStandardOutput = true;
  myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  myProcess.Start();
  myProcess.WaitForExit();
}

this results in

<?xml version="1.0"?>
<package >
  <metadata>
    <id>\\network-drive\Network-Folder\MyDLLs\Test.dll</id>
    <version>1.0.0</version>
    ....

How can I specify the packageID to something like My.TestDLL?

I tried doing something like

nuget spec My.TestDLL -AssemblyPath \\network-drive\Network-Folder\MyDLLs\Test.dll

But have no idea where the nuspec file went as it was not in the directory.

Sir Funk
  • 23
  • 4

1 Answers1

0

You are creating a new command line to use and then passing the command to it. Think about opening up a new command window. Where does it default to?

If you didn't already have NuGet stored in the environment variables (assumption), you would have to either specify the full path to NuGet.exe or set the working directory to the folder which has the NuGet executable. Since you are not doing either, the command window is using the default location to create that .nuspec file.

I would set the working directory for the ProcessStartInfo object. When you set the working directory, you are specifying where you want NuGet to create the file on disc.

techvice
  • 1,315
  • 1
  • 12
  • 24