JesseBuesking
JesseBuesking

Reputation: 6596

MSBuild Web API project not creating a deployable package

I'm trying to create a deployable package from a web api project, and I'm getting the error

error MSB4057: The target "Package" does not exist in the project.

When I try to build a web application running MVC5, I have no issue.

The command to build the MVC5 application is

MSBuild.exe Project.Web.csproj /P:Configuration=Debug /T:Package

The command for the failing web api application is

MSBuild.exe Project.Api.csproj /P:Configuration=Debug /T:Package

I'm assuming that perhaps I need to install something, but I have no idea what. Can anyone tell what I'm doing wrong?

Note: If you need more information let me know.

Upvotes: 1

Views: 732

Answers (1)

JesseBuesking
JesseBuesking

Reputation: 6596

I read around and saw that I might have to add the property VisualStudioVersion, but whenever I tried it the package still failed.

I was just comparing the csproj files and noticed that the following property group was missing:

<PropertyGroup>
  <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
  <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

Adding this fixes it, so maybe I need both the VisualStudioVersion and VSToolsPath.

After that I quickly ran into deployment issues, which in turn were related to more config differences. This time it was the top-most node Project. The attribute ToolsVersion was set to 4.0 in one project, and 12.0 in the other. Setting them both to 4.0 fixed it, probably because I was compiling with MSBuild 4? I'm not going to lie, it was mostly trial-and-error for a few days to figure this out. God I hope I never have to touch this code again...

Upvotes: 1

Related Questions