teamcity error MSB4057: The target “pack” does not

2019-07-10 16:26发布

问题:

Unable to create packages for a Dot Net Core project using 4.7 framework. I am using msbuild /t:pack /p:COnfiguration=Release command in teamcity to create a package.

<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
 <TargetFramework>net471</TargetFramework>
 </PropertyGroup>
</Project> 

NuGet.Build.Tasks.Pack is installed in the project.

we use only .net core csproj structure but not .net core as target framework so it can't be compiled via .net CLI - that's why we build projects via MSBuild and not .net CLI Please guide how to create packages for such project.

回答1:

Seems that the way TeamCity operates with msbuild, by default it creates a wrapper script and then calls that. Something in the way the wrapper opperates prevents it from working properly.

At the TeamCity MSBUILD Docs there is a note on Implementation Note that you can disable the wrapper. I tried this and it seemed like it works.

To disable the wrapper behaviour teamcity.msbuild.generateWrappingScript to false. I did this by adding teamcity.msbuild.generateWrappingScript as a configuration parameter on the build config with the value "false". Then I re-ran the build and it behaved as expected.