VSTS Build Nuget Packager不起作用

时间:2017-05-16 12:51:45

标签: nuget azure-pipelines azure-pipelines-build-task azure-artifacts

我正在尝试在构建之后打包一个库以在我的VSTS包Feed上发布。

但Nuget Packager的任务不起作用。我已经尝试了很多设置组合,但我无法使它有效。

我尝试使用.Net Core和.Net 4.6.2打包库。

尝试使用.Net Core或.Net 4.6.2打包时出现以下错误:

## [error]项目的默认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年主持

内部版本号格式:$(日期:yyyyMMdd)。$(rev:.r).0

enter image description here

.net核心的.csproj如下:

<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的完整日志是:

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 

有没有人知道发生了什么?

谢谢!

1 个答案:

答案 0 :(得分:3)

NuGet打包程序步骤不适用于基于SDK的csproj格式(通常是.NET Standard或.NET Core项目)。

可以使用命令行步骤打包项目以调用dotnet pack或使用.NET Core构建步骤(在构建步骤中将调用包装到dotnet)。请注意,命令选择器当前不会列出pack,但该字段接受任何输入: enter image description here