2
votes

I'm trying to package one library after build to publish on my VSTS Packages feed.

But the task Nuget Packager is not working. I've tried lots of combinations of settings, but I could not make it works.

I've tried to package the library using .Net Core and .Net 4.6.2.

I'm getting the following error when trying to pack with .Net Core or .Net 4.6.2:

##[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 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\myproject.csproj

I'm using the following settings:

Agent: Hosted 2017

Build Number Format: $(date:yyyyMMdd).$(rev:.r).0

enter image description here

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>

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?

Thank you!

1

1 Answers

3
votes

The NuGet packer step doesn't work on SDK-based csproj formats (usually .NET Standard or .NET Core projects).

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: enter image description here