Web Api Project Fails to build with Visual Studio

2019-07-22 19:28发布

问题:

I have a project inside a solution and Visual Studio Team Services is setup to do continuous build.

The test project that includes the Web API project builds fine and even includes the artifacts from the web api project, but when I look at the drop folder from artifacts view it doesn't have a sub folder for the website.

This is done with a new default Visual Studio Build definition with bone stock settings. (no amount of playing around works either)

(I'd put in a screen shot but literally just create a new build definition as choose visual studio and continuous integration and click ok, and that's exactly what this is.)

The log file for the build step doesn't show that it even tries to build the csproj for the web api project and just skips right to the Tests project. (and no errors in the log either)

Going to configuration manager for that configuration (and all configurations) and the project in question is set to build.

It builds properly in that configuration with that project just fine. It publishes from Visual Studio with that project just fine.

Any ideas why it won't build the project?

回答1:

According to the information you provided, you are using a default build definition for Visual Studio CI without any other settings. This definition does not generate the web app publish files.

Try adding following MSBuild Arguments in "Visual Studio Build" step and then queue a new build:

/p:DeployOnBuild=true /p:outdir=$(build.artifactstagingdirectory)

Update: Since you want to deploy the website by Azure Deploy from Release Management, you can just upload the deployment packages to drop. To do this, change the MSBuild Arguments to following:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"

And then you can go to Release Managament, in the "Azure Web App Deployment" step, set "Web Deploy Package" to "$(System.DefaultWorkingDirectory)\**\ProjectName.zip".