5

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

执行的命令是:

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

我得到的输出是:

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

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

编辑: 我下载了 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();
         }
     }
}

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

4

5 回答 5

4

在nuget程序中使用属性Platform来-Properties参数

-Properties Platform=$(Platform)

其中 $(Platform) 是您的项目平台之一(在 csproj 文件中定义,通常是 x86、'Any CPU'、..)。

即在你的情况下,运行类似:

nuget.exe pack "$(ProjectPath)" -Properties Configuration="$(ConfigurationName)" Platform="$(Platform)" -OutputDir "$(ProjectDir)..\Apps"
于 2015-03-13T16:10:39.697 回答
3

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

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

于 2013-06-18T08:07:37.043 回答
2

我基本上遇到了同样的问题,这是我在源代码管理中携带的旧 nuget 版本,我删除了 .nuget 文件夹,然后通过选择从 Visual Studio 卸载了 nuget

工具 > 扩展和更新,

选择 nuget & 卸载,然后执行相同的过程,但要安装它,只需确保您在“在线”存储库中进行搜索。

于 2015-10-17T02:07:52.573 回答
0

我必须从 Updates And Extensions 更新 Nuget Manager。重新启动VS,它工作正常。

于 2016-06-10T16:34:40.193 回答
0

对我来说,问题是Debug文件夹内没有 .dll 并且没有-properties Configuration=Release选项 nuget 通常会尝试在Debug文件夹中查找 dll。

手动运行nuget pack给了我一个有用的错误信息。将其作为构建后事件运行,我收到了与您相同的晦涩错误消息。

于 2016-10-25T20:43:23.070 回答