![](/img/trans.png)
[英]Nuget Automatic Restore - Specifying custom repositories for TFS Build
[英]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.