【问题标题】:Nuget BasePath option is 'unknown'Nuget BasePath 选项为“未知”
【发布时间】:2016-01-01 20:05:02
【问题描述】:

我正在尝试使用项目文件中的以下代码将 NuGet 生成过程添加为 C# 项目中的 AfterBuild 事件:

 <Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
    <Message Text="**** Starting after-build process= ****" />
    <Exec Command="nuget.exe update -self" />
    <Copy SourceFiles="$(ProjectDir)bin\release\$(ProjectName).dll" DestinationFolder="$(SolutionDir)Nuget\$(ProjectName)\lib\Net45" />
    <Delete Files="$(SolutionDir)Nuget\*.nupkg" />
    <Exec Command="nuget.exe pack $(ProjectName).nuspec -Properties &quot;Configuration=Release&quot; -BasePath=&quot;$(SolutionDir)Nuget\$(ProjectName)&quot; -OutputDirectory=&quot;$(SolutionDir)Nuget&quot;"  />
    <Message Text="**** After-build process completed ****" />
  </Target>

但我在构建输出窗格中收到一条消息:

Unknown option: '-BasePath="<the path shown in here>"

我使用的是 NuGet.exe 版本 3.3.0,并且我将 https://docs.nuget.org/consume/command-line-reference#pack-command 引用为我的“如何使用”信息。

为了查看 Visual Studio 2015 是否影响了某些东西,我尝试从构建输出窗格复制已执行的命令,插入正确的路径,然后在 VS 命令提示符下执行它。这失败了,同样的评论,所以它似乎是一个 NuGet 问题。

【问题讨论】:

    标签: msbuild visual-studio-2015 nuget post-build-event


    【解决方案1】:

    我知道现在已经很晚了,但问题似乎是您使用-BasePath= 作为参数,它应该只说-BasePath (请注意替换您的“=”字符的空格)。 参数不是变量,“赋值”时没有等号 - 只需将值放在参数名称后面的空格后面,如下所示:

    -BasePath &quot;$(SolutionDir)Nuget\$(ProjectName)&quot;
    

    顺便说一句,如果您尝试在 (powershell) 脚本中使用带有参数的 NuGet.exe,则会出现类似的问题。 See Samuel Lais excellent article about parameters in scripts.

    【讨论】:

      猜你喜欢
      • 2013-02-13
      • 2017-03-29
      • 1970-01-01
      • 2022-10-21
      • 2015-06-21
      • 2018-08-09
      • 1970-01-01
      • 1970-01-01
      • 2018-03-29
      相关资源
      最近更新 更多