W van Noort W van Noort - 1 year ago 95
C# Question

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?

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");

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);

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

Answer Source

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!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download