Rui Jarimba
Rui Jarimba

Reputation: 17944

VSTS - Compile aspx pages on build

I have a task on a Visual Studio Team Services configured as follows:

enter image description here

The solution contains an ASP.NET Web Forms application. The task compiles the solution but unfortunately compilation errors on .aspx files are ignored. Is there any way to check for errors on .aspx pages on build?

Upvotes: 1

Views: 906

Answers (2)

Rui Jarimba
Rui Jarimba

Reputation: 17944

As already mentioned by Luca, PrecompileBeforePublish does the trick.

I decided to post another answer because the MSBuild arguments he gave as an example did not work for me. I used the following arguments:

/t:Package 
/p:PackageLocation="$(build.artifactstagingdirectory)\website.zip"     
/p:OutputPath=.\bin 
/p:Configuration=$(BuildConfiguration) 
/p:PrecompileBeforePublish=true

Build is now detecting errors in the .aspx pages such as missing resources:

enter image description here

Upvotes: 0

Luca Cappa
Luca Cappa

Reputation: 1989

TL;DR Just set the MSBuild property PrecompileBeforePublish to 'true'

Long version:
The preferred option is to create a web package (a .zip file), that you could then feed to VSTS Build/Release tasks that would deploy it on Azure App Service or IIS.

In order to create a web package trigger the Web Publishing Pipeline during build by passing these additional arguments to MSBuild (on the Visual Studio Build task):

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

This would either precompile the .aspx file as well as copying the .zip file locally on the artifact staging directory on the agent machine. Use the $(build.artifactstagingdirectory) variable to refer to this directory in subsequent tasks in order to publish this artifact.

Upvotes: 3

Related Questions