创建 nuget 包失败并显示“路径不合法”

W v*_*ort 5 c# msbuild nuget

在后期构建步骤中,我们创建 nuget 包。由于某些原因,这在我的机器上总是失败,而它在其他开发人员的机器上工作。

执行的命令是:

nuget.exe  pack "$(ProjectPath)" -Properties Configuration=$(ConfigurationName) -OutputDir "$(ProjectDir)..\Apps"
Run Code Online (Sandbox Code Playgroud)

我得到的输出是:

Packing files from ''.
Using 'Organisation.AppName.Modules.Kcs.nuspec' for metadata.
The path is not of a legal form.
Run Code Online (Sandbox Code Playgroud)

对于其他开发人员,第一行包含目录。它在我的盒子上的工作方式不同的原因是什么?我可以设置选项来改变这种行为吗?

编辑: 我下载了 nuget 源,发现事情开始出错了。通过一个小的测试程序,我可以模拟它:

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();
         }
     }
}
Run Code Online (Sandbox Code Playgroud)

在我的机器上,targetdir 为空,在另一台机器上,targetdir 指向有效目录。

W v*_*ort 3

终于找到了答案。该线程帮助我找到了问题: http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/d3c6e2de-1e87-49c2-b059-df074868e315/

在我的机器上有一个环境变量“platform”,其值为“BWS”。删除它,一切正常!