簡體   English   中英

TFS自動構建:Nuget Pack失敗,代碼為(1)

[英]TFS Automatic Build : Nuget Pack fail with code(1)

我正在嘗試在WFS項目的TFS中實現自動構建。 自動構建的效果很好,但是我無法為該項目准備一個nuget包。

這是我在TFS中的構建過程:

失敗后捕獲構建過程

如果我刪除了NuGet pack和NuGet push,它將正常工作。

這是我通過TFS收到的消息:

Found packages.config. Using packages listed as dependencies
NuGet.CommandLine.CommandLineException: Unable to find 'Extended.Wpf.Toolkit.3.3.0.nupkg'. Make sure the project has been built.
   at NuGet.CommandLine.ProjectFactory.AddDependencies(Dictionary`2 packagesAndDependencies)
   at NuGet.CommandLine.ProjectFactory.ProcessDependencies(PackageBuilder builder)
   at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded, PackageBuilder builder)
   at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path)
   at NuGet.CommandLine.PackCommand.ExecuteCommand()
   at NuGet.CommandLine.Command.ExecuteCommandAsync()
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
Unable to find 'Extended.Wpf.Toolkit.3.3.0.nupkg'. Make sure the project has been built.
##[error]The nuget command failed with exit code(1) and error(Unable to find 'Extended.Wpf.Toolkit.3.3.0.nupkg'. Make sure the project has been built.)

在日志中,它說沒有找到“ Extended.Wpf.Toolkit.3.3.0.nupkg”。 我在構建之前確實使用了NuGet Restore,並且構建是正確的。 在TFS的日志中,我可以看到它使用了“ Extended.Wpf.Toolkit.3.3.0”

我已經嘗試在NuGet用於打包的命令上添加-Prop Platform=AnyCPU ,但它沒有任何改變。 我在計算機上運行了該命令,它可以正常工作。

這是我在查找修復程序時已經檢查過的頁面:

當您打包並選擇.csproj文件時,您可能缺少配置。

如果已選擇$(BuildConfiguration)作為要打包配置選項。

您還必須指定BuildConfiguration的值

在此處輸入圖片說明

看看使用**\\*.csproj**\\*.nuspec

為簡單項目指定.csproj文件(例如**\\*.csproj )。 在這種情況下:

  • 打包程序會編譯.csproj文件進行打包。
  • 您必須將配置指定為打包(請參見下文)。
  • 您不必檢入.nuspec文件。 如果您確實簽入,則打包程序將接受其設置並替換令牌,例如$ id $和$ description $。

為更復雜的項目指定.nuspec文件(例如**\\*.nuspec ),例如,需要在單獨的步驟中進行編譯和打包的多平台方案。 在這種情況下:

  • 打包程序不會編譯.csproj文件進行打包。
  • 每個項目只有在已簽入.nuspec文件的情況下才打包。
  • 打包程序不會替換.nuspec文件中的令牌(元素除外,請參閱下面的使用內部版本號對程序包進行版本控制)。 您必須為<id/>
    <description/> 最常見的方法是對
    .nuspec文件中的值。

終於我能夠解決這個問題

我發現的解決方法是將.nuspec文件添加到我的項目中。 我將NuGet pack任務更改為使用nuspec而不是csproj。

在那之后(據我所知),一切都運行良好(除了包圖標尚不可見)。 但這是另一個故事!

nuspec的參考在這里https://docs.microsoft.com/en-us/nuget/reference/nuspec

在此處可以找到默認的nuspec https://docs.microsoft.com/zh-cn/nuget/create-packages/creating-a-package

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM