W van Noort
W van Noort

Reputation: 383

create nuget package fails with 'Path is not of a legal form'

In a post build step we create nuget packages. For some reasons this always fails on my machine, while it works on other developers machines.

The command executed is:

nuget.exe  pack "$(ProjectPath)" -Properties Configuration=$(ConfigurationName) -OutputDir "$(ProjectDir)..\Apps"

The output i get is:

Packing files from ''.
Using 'Organisation.AppName.Modules.Kcs.nuspec' for metadata.
The path is not of a legal form.

For other developers the first line contains the directory. What can be the reason it is working differently on my box? Are there options i can set to change this behavior?

Edit: I downloaded the nuget source and found the point things start to go wrong. With a small test program i can simulate it:

using System;
using Microsoft.Build.Evaluation;

namespace CheckTarget
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine("usage: CheckTarget projectfile.csproj");
                Console.WriteLine();
                return;
             }

             string path = args[0];
             var project = new Project(path);


             Console.WriteLine("TargetDir = {0}", project.GetProperty("TargetDir") != null ? project.GetProperty("TargetDir").EvaluatedValue : string.Empty);
             Console.WriteLine("TargetPath = {0}", project.GetProperty("TargetPath").EvaluatedValue);
             Console.ReadKey();
         }
     }
}

On my machine the targetdir is null, on another machine the targetdir points to valid directory.

Upvotes: 5

Views: 6448

Answers (5)

user764754
user764754

Reputation: 4226

For me the problem was that no .dll was inside the Debug folder and without the -properties Configuration=Release option nuget usually tries to find a dll in the Debug folder.

Running nuget pack manually gave me an useful error message. Running it as post build event I got the same obscure error message as you.

Upvotes: 0

Francisco G
Francisco G

Reputation: 1494

I had to update the Nuget Manager from Updates And Extensions. Restarted VS, and it worked fine.

Upvotes: 0

pedrommuller
pedrommuller

Reputation: 16056

I had the same problem basically it was an old nuget version that I carried in my source control, I deleted the .nuget folder then I uninstalled nuget from visual studio, by selecting

tools > extensions & updates,

select nuget & uninstall and then do the same process but for Installing it, just make sure you al searching in the "online" repository.

Upvotes: 2

honzakuzel1989
honzakuzel1989

Reputation: 2520

Use property Platform to -Properties parameter in nuget program

-Properties Platform=$(Platform)

where $(Platform) is one of your project platform (defined in csproj file, typically x86, 'Any CPU', ..).

ie in your case, run something like:

nuget.exe pack "$(ProjectPath)" -Properties Configuration="$(ConfigurationName)" Platform="$(Platform)" -OutputDir "$(ProjectDir)..\Apps"

Upvotes: 4

W van Noort
W van Noort

Reputation: 383

Finally found the answer. This thread helped me locate the problem: http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/d3c6e2de-1e87-49c2-b059-df074868e315/

On my machine there was an environment variable 'platform' with value 'BWS'. Deleted it and things are working!

Upvotes: 3

Related Questions