TFS 自动构建:Nuget 包失败,代码为 (1)
TFS Automatic Build : Nuget Pack fail with code(1)
我正在尝试在 TFS 中为 WPF 项目实现自动构建。
自动构建效果很好,但我无法为项目准备 nuget 包。
这是我在 TFS 中的构建过程:
如果我删除 NuGet 包和 NuGet 推送,它可以正常工作。
这是我通过 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
但它没有改变任何东西。我 运行 在我的计算机上执行了命令并且它起作用了。
以下是我在搜索修复程序时已经检查过的页面:
- https://developercommunity.visualstudio.com/content/problem/245349/the-nuget-command-failed-with-exit-code1-and-error.html
- NuGet pack for TFS Continuous Integration
- NuGet pack fails with "Unable to find '@(_OutputPathItem->'%(FullPath)..."
- VisualStudio Online and pack Nuget packages
- http://timjames.me/blog/2015/07/29/nuget-pack-fails-with-exited-with-code-1/
- https://www.benday.com/2017/05/03/walkthrough-publish-to-private-nuget-server-from-tfs2017-build/
我终于能够解决这个问题
我找到的解决方法是将 .nuspec 文件添加到我的项目中。我更改了 NuGet 包任务以使用 nuspec 而不是 csproj。
此后一切正常(据我所知)除了尚不可见的包图标。但那是另一回事了!
nuspec 的参考在这里 https://docs.microsoft.com/en-us/nuget/reference/nuspec
在此处找到默认的 nuspec https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package
打包和select .csproj
文件时可能缺少配置。
如果您select将$(BuildConfiguration)
作为您的打包配置选项。
您还必须指定 BuildConfiguration 的值
看看**\*.csproj
和**\*.nuspec
的区别
Specify .csproj files (for example, **\*.csproj
) for simple
projects. In this case:
- The packager compiles the .csproj files for packaging.
- You must specify Configuration to Package (see below).
- You do not have to check in a .nuspec file. If you do check one in, the packager honors its settings and replaces tokens such as $id$ and
$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. In this case:
- The packager does not compile the .csproj files for packaging.
- Each project is packaged only if it has a .nuspec file checked in.
- The packager does not replace tokens in the .nuspec file (except the element, see Use build number to version package,
below). You must supply values for elements such as
<id/>
and
<description/>
. The most common way to do this is to hardcode the
values in the .nuspec
file.
我正在尝试在 TFS 中为 WPF 项目实现自动构建。 自动构建效果很好,但我无法为项目准备 nuget 包。
这是我在 TFS 中的构建过程:
如果我删除 NuGet 包和 NuGet 推送,它可以正常工作。
这是我通过 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
但它没有改变任何东西。我 运行 在我的计算机上执行了命令并且它起作用了。
以下是我在搜索修复程序时已经检查过的页面:
- https://developercommunity.visualstudio.com/content/problem/245349/the-nuget-command-failed-with-exit-code1-and-error.html
- NuGet pack for TFS Continuous Integration
- NuGet pack fails with "Unable to find '@(_OutputPathItem->'%(FullPath)..."
- VisualStudio Online and pack Nuget packages
- http://timjames.me/blog/2015/07/29/nuget-pack-fails-with-exited-with-code-1/
- https://www.benday.com/2017/05/03/walkthrough-publish-to-private-nuget-server-from-tfs2017-build/
我终于能够解决这个问题
我找到的解决方法是将 .nuspec 文件添加到我的项目中。我更改了 NuGet 包任务以使用 nuspec 而不是 csproj。
此后一切正常(据我所知)除了尚不可见的包图标。但那是另一回事了!
nuspec 的参考在这里 https://docs.microsoft.com/en-us/nuget/reference/nuspec
在此处找到默认的 nuspec https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package
打包和select .csproj
文件时可能缺少配置。
如果您select将$(BuildConfiguration)
作为您的打包配置选项。
您还必须指定 BuildConfiguration 的值
看看**\*.csproj
和**\*.nuspec
Specify .csproj files (for example,
**\*.csproj
) for simple projects. In this case:
- The packager compiles the .csproj files for packaging.
- You must specify Configuration to Package (see below).
- You do not have to check in a .nuspec file. If you do check one in, the packager honors its settings and replaces tokens such as $id$ and $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. In this case:
- The packager does not compile the .csproj files for packaging.
- Each project is packaged only if it has a .nuspec file checked in.
- The packager does not replace tokens in the .nuspec file (except the element, see Use build number to version package, below). You must supply values for elements such as
<id/>
and
<description/>
. The most common way to do this is to hardcode the
values in the.nuspec
file.