gpt4 book ai didi

c# - 创建 nuget 包失败,错误为 'Path is not of a legal form'

转载 作者:太空狗 更新时间:2023-10-30 00:32:34 25 4
gpt4 key购买 nike

在后期构建步骤中,我们创建 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 指向有效目录。

最佳答案

在nuget程序中使用property Platform to -Properties参数

-Properties Platform=$(Platform)

其中 $(Platform) 是您的项目平台之一(在 csproj 文件中定义,通常为 x86,“任何 CPU”,..)。

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

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

关于c# - 创建 nuget 包失败,错误为 'Path is not of a legal form',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17066856/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com