[英]TFS Automatic Build : Nuget Pack fail with code(1)
I'm trying to implement automatic builds in TFS for a WPF project. 我正在尝试在WFS项目的TFS中实现自动构建。 The automatic build works great, but I can't prepare a nuget package with the project. 自动构建的效果很好,但是我无法为该项目准备一个nuget包。
Here is my build process in TFS : 这是我在TFS中的构建过程:
If I remove NuGet pack and NuGet push, it works without trouble. 如果我删除了NuGet pack和NuGet push,它将正常工作。
Here is the messages I get by TFS: 这是我通过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.)
In the logs, it says it doesn't find 'Extended.Wpf.Toolkit.3.3.0.nupkg'. 在日志中,它说没有找到“ Extended.Wpf.Toolkit.3.3.0.nupkg”。 I do use NuGet Restore before my build, and the build is correct. 我在构建之前确实使用了NuGet Restore,并且构建是正确的。 In the logs of TFS, I can see it uses 'Extended.Wpf.Toolkit.3.3.0' 在TFS的日志中,我可以看到它使用了“ Extended.Wpf.Toolkit.3.3.0”
I already tried to add -Prop Platform=AnyCPU
on the commands used by NuGet for packing but it didn't change anything. 我已经尝试在NuGet用于打包的命令上添加-Prop Platform=AnyCPU
,但它没有任何改变。 I ran the command on my computer and it worked. 我在计算机上运行了该命令,它可以正常工作。
Here are the pages I already checked in my search of a fix : 这是我在查找修复程序时已经检查过的页面:
You may lack the configuration when you do the pack and select .csproj
file. 当您打包并选择.csproj
文件时,您可能缺少配置。
If you have selected the $(BuildConfiguration)
as your Configuration to package option. 如果已选择$(BuildConfiguration)
作为要打包的配置选项。
You have to also specify the value of BuildConfiguration 您还必须指定BuildConfiguration的值
Take a look at the difference of using **\\*.csproj
and **\\*.nuspec
看看使用**\\*.csproj
和**\\*.nuspec
Specify .csproj files (for example,
**\\*.csproj
) for simple projects. 为简单项目指定.csproj文件(例如**\\*.csproj
)。 In this case: 在这种情况下:
- The packager compiles the .csproj files for packaging. 打包程序会编译.csproj文件进行打包。
- You must specify Configuration to Package (see below). 您必须将配置指定为打包(请参见下文)。
- You do not have to check in a .nuspec file. 您不必检入.nuspec文件。 If you do check one in, the packager honors its settings and replaces tokens such as $id$ and $description$. 如果您确实签入,则打包程序将接受其设置并替换令牌,例如$ id $和$ description $。
Specify .nuspec files (for example,
**\\*.nuspec
) for more complex projects, such as multi-platform scenarios in which you need to compile and package in separate steps. 为更复杂的项目指定.nuspec文件(例如**\\*.nuspec
),例如,需要在单独的步骤中进行编译和打包的多平台方案。 In this case: 在这种情况下:
- The packager does not compile the .csproj files for packaging. 打包程序不会编译.csproj文件进行打包。
- Each project is packaged only if it has a .nuspec file checked in. 每个项目只有在已签入.nuspec文件的情况下才打包。
- The packager does not replace tokens in the .nuspec file (except the element, see Use build number to version package, below). 打包程序不会替换.nuspec文件中的令牌(元素除外,请参阅下面的使用内部版本号对程序包进行版本控制)。 You must supply values for elements such as
<id/>
and 您必须为<id/>
和
<description/>
.<description/>
。 The most common way to do this is to hardcode the 最常见的方法是对
values in the.nuspec
file..nuspec
文件中的值。
Finally I was able to fix this 终于我能够解决这个问题
The workaround I found was to add a .nuspec file to my project. 我发现的解决方法是将.nuspec文件添加到我的项目中。 I changed the NuGet pack task to use the nuspec instead of the csproj. 我将NuGet pack任务更改为使用nuspec而不是csproj。
Everything worked fine after that (as far as I can see) except for the package icon which is not visible yet. 在那之后(据我所知),一切都运行良好(除了包图标尚不可见)。 But that's another story ! 但这是另一个故事!
The reference for nuspec is here https://docs.microsoft.com/en-us/nuget/reference/nuspec nuspec的参考在这里https://docs.microsoft.com/en-us/nuget/reference/nuspec
A default nuspec is found here https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package 在此处可以找到默认的nuspec https://docs.microsoft.com/zh-cn/nuget/create-packages/creating-a-package
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.