问题描述
我正在尝试在构建后打包一个库以发布到我的VSTS打包供稿上。
I'm trying to package one library after build to publish on my VSTS Packages feed.
但是Nuget Packager任务无法正常工作。我尝试了许多设置组合,但无法使其正常工作。
But the task Nuget Packager is not working. I've tried lots of combinations of settings, but I could not make it works.
我尝试使用.Net Core和.Net 4.6打包该库。 2。
I've tried to package the library using .Net Core and .Net 4.6.2.
尝试与.Net Core或.Net 4.6.2打包时出现以下错误:
I'm getting the following error when trying to pack with .Net Core or .Net 4.6.2:
## [错误]项目的默认XML名称空间必须是MSBuild XML名称空间。如果项目是以MSBuild 2003格式编写的,请在元素中添加xmlns = http://schemas.microsoft.com/developer/msbuild/2003。如果项目是用旧的1.0或1.2格式创作的,请将其转换为MSBuild 2003格式。 d:\a\12\s\myproject.csproj
我正在使用以下设置:
代理:托管于2017
Agent: Hosted 2017
内部版本号格式:$(date:yyyyMMdd)。$(rev:.r).0
Build Number Format: $(date:yyyyMMdd).$(rev:.r).0
.net核心的.csproj如下:
The .csproj for .net core is the following:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Globals">
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<Import Project="..\..\myproject.shared.projitems" Label="Shared" />
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
<PackageReference Include="WindowsAzure.Storage" Version="8.1.1" />
</ItemGroup>
</Project>
.Net Core的完整日志为:
The complete log for .Net Core is:
2017-05-16T12:25:40.4059161Z ##[section]Starting: NuGet Packager
2017-05-16T12:25:40.4069169Z ==============================================================================
2017-05-16T12:25:40.4069169Z Task : NuGet Packager
2017-05-16T12:25:40.4069169Z Description : Creates nupkg outputs from csproj or nuspec files
2017-05-16T12:25:40.4069169Z Version : 0.1.72
2017-05-16T12:25:40.4069169Z Author : Lawrence Gripper
2017-05-16T12:25:40.4069169Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=627416)
2017-05-16T12:25:40.4069169Z ==============================================================================
2017-05-16T12:25:42.1843658Z Preparing task execution handler.
2017-05-16T12:25:47.7782379Z Executing the powershell script: d:\a\_tasks\NuGetPackager_333b11bd-d341-40d9-afcf-b32d5ce6f24b\0.1.72\NuGetPackager.ps1
2017-05-16T12:25:48.1582506Z Find-Files -SearchPattern d:\a\12\s\**\*.csproj -RootFolder d:\a\12\s
2017-05-16T12:25:48.1582506Z
2017-05-16T12:25:48.1582506Z
2017-05-16T12:25:48.2452532Z C:\LR\MMS\Services\mms\TaskAgentProvisioner\Tools\agents\2.116.1\externals\nuget\NuGet.exe pack "d:\a\12\s\SpaceNeedle.NetFX\Net4\SpaceNeedle.NetFX.Net4\SpaceNeedle.NetFX.Net4.csproj" -OutputDirectory "d:\a\12\s" -Properties Configuration=release
2017-05-16T12:25:49.5712932Z MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework\v4.0.30319'.
2017-05-16T12:25:49.5712932Z Attempting to build package from 'SpaceNeedle.NetFX.Net4.csproj'.
2017-05-16T12:25:50.6143198Z Packing files from 'd:\a\12\s\SpaceNeedle.NetFX\Net4\SpaceNeedle.NetFX.Net4\bin\Release'.
2017-05-16T12:25:50.9343273Z Found packages.config. Using packages listed as dependencies
2017-05-16T12:25:50.9463282Z WARNING: Description was not specified. Using 'Description'.
2017-05-16T12:25:51.0333303Z Successfully created package 'd:\a\12\s\SpaceNeedle.NetFX.Net4.0.1.0.0.nupkg'.
2017-05-16T12:25:51.0763302Z C:\LR\MMS\Services\mms\TaskAgentProvisioner\Tools\agents\2.116.1\externals\nuget\NuGet.exe pack "d:\a\12\s\SpaceNeedle.NetFX\NetFX\SpaceNeedle.NetFX\SpaceNeedle.NetFX.csproj" -OutputDirectory "d:\a\12\s" -Properties Configuration=release
2017-05-16T12:25:51.4743413Z MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework\v4.0.30319'.
2017-05-16T12:25:51.4863414Z Attempting to build package from 'SpaceNeedle.NetFX.csproj'.
2017-05-16T12:25:51.5313430Z ##[error]The default XML namespace of the project must be the MSBuild XML namespace. If the project is authored in the MSBuild 2003 format, please add xmlns="http://schemas.microsoft.com/developer/msbuild/2003" to the <Project> element. If the project has been authored in the old 1.0 or 1.2 format, please convert it to MSBuild 2003 format. d:\a\12\s\SpaceNeedle.NetFX\NetFX\SpaceNeedle.NetFX\SpaceNeedle.NetFX.csproj
2017-05-16T12:25:51.5703444Z ##[error]System.Exception: Unexpected exit code 1 returned from tool NuGet.exe
2017-05-16T12:25:51.5703444Z at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord()
2017-05-16T12:25:51.5713439Z at System.Management.Automation.CommandProcessor.ProcessRecord()
2017-05-16T12:25:51.5943443Z ##[error]PowerShell script completed with 1 errors.
2017-05-16T12:25:51.5953445Z ##[section]Finishing: NuGet Packager
有人知道发生了什么吗?
Does anyone have idea of what is happening?
谢谢!
推荐答案
NuGet打包程序步骤不适用于基于SDK的 csproj
格式(通常是.NET Standard或.NET Core项目)。
The NuGet packer step doesn't work on SDK-based csproj
formats (usually .NET Standard or .NET Core projects).
可以使用命令行步骤调用 dotnet pack
或使用.NET Core构建步骤(将调用包装到 dotnet
)。请注意,命令选择器当前未列出 pack
,但是该字段接受任何输入:
The projects can be packed using a command line step to call dotnet pack
or by using the .NET Core build step (which wraps the call to dotnet
in a build step). Note that the command selector currently does not list pack
, but the field accepts any input:
这篇关于VSTS Build Nuget Packager无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!