4
votes

We are using VSTS build using ASP.Net template. We are passing MSBuild Arguments as below-

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

We see no build error. From the log we observe a line -

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /LRM -p ..\LRM\ -u -f -d PrecompiledWeb\LRM\

where LRM is the .NET sln name which we are building. This sln contains multiple projects along with the LRM website.

At the end of the build pipeline we see no artifact generated. We see a warning at the "Publish Build Artifacts" saying -

2018-01-03T06:07:47.9208838Z ##[warning]Directory 'D:\VSTS Agents\DEV-QAS\A1\66\a' is empty. Nothing will be added to build artifact 'drop'.

4

4 Answers

4
votes

Use below as msbuild arguments (/p:OutDir="$(build.stagingDirectory)" is the diffrence)

/p:TransformConfigFiles=true /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:OutDir="$(build.stagingDirectory)"

Use Publish task Path to publish as "$(build.stagingDirectory)\_PublishedWebsites" if you only want the website output. If all the files in staging directory required use "$(build.stagingDirectory)" as path to publish

enter image description here

0
votes

I don't know the cause, but perhaps this alternative set of MSDeploy-targeted MSBuild parameters will prove to be a workaround.

/p:SkipInvalidConfigurations=true /p:DeployTarget=Package /p:PackageTempRootDir="$(Build.ArtifactStagingDirectory)"
0
votes

It is the website, so you can’t publish it as the web application.

First, as ChamindaC said that you can specify OutDir argument, but it won’t generate the web deployment package, you can archive the folder to zip through Archive task. (Note: the value should be /p:OutDir="$(build.stagingDirectory)\\")

Secondly, it can generate the publishproj file once creating publish profile (right click website > Publish Web App). So you can specify that file in Visual Studio Build or MSBuild task with your MSBuild Arguments to publish website to web deployment package.

0
votes

enter image description here

ASP.Net Web API MSBuild Arguments: /p:OutDir=$(Build.ArtifactStagingDirectory) /p:SkipInvalidConfigurations=true

Publish Build Artifacts : Path to Publish: $(Build.ArtifactStagingDirectory)_PublishedWebsites

The above configuration is working for me, please check the image for details.