Where is my _PublishedWebsites folder?

For an ASP.net application, the vNext build system will generate the binaries for the web application in Visual Studio and will not create the _PublishedWebsites folder with the entire web application without some additional settings in the MSBuild argument section of the Visual Studio Build task.

The following instructions show how to create a build of the ASP.net application and produce the _PublishedWebsites folder in order to use for a release in Release Management, or another release tool.

Setup:

This is a basic MVC web application called DemoWebFormsApp and the build definition contains two build tasks, the Visual Studio Build and Publish Artifact task.

image

In the Visual Studio Build task, the solution file is selected and there are no MSBuild arguments

image

The Publish Artifact task has the Path to Publish set to the Build Artifact Staging folder, which is a folder on the build server where files are copied and uploaded to TFS.

image

The build completes and in the Publish Artifact task and the log files shows something similar :

##[warning]Directory 'C:\_Agents\TFS_Agent1\Agent_Bin\_work\7\a' is empty. Nothing will be added to build artifact 'DropZone'.

This means the Published Artifact task is looking in the location on the build server for the files to upload back into TFS and cannot find the files in the folder. This is because the MSBuild process only compiles the binaries and additional arguments are required to publish the files to the folder.

Looking at the Build Solution task in the log file, it will show something similar where the binary files are created for the web application, but no Published Web site folder with the .aspx files:

_CopyAppConfigFile:
Copying file from "Web.config" to "bin\DemoWebFormsApp.dll.config".
CopyFilesToOutputDirectory:
Copying file from "obj\Debug\DemoWebFormsApp.dll" to "bin\DemoWebFormsApp.dll".
DemoWebFormsApp -> C:\_Agents\TFS_Agent1\Agent_Bin\_work\7\s\DemoWebFormsApp\bin\DemoWebFormsApp.dll
Copying file from "obj\Debug\DemoWebFormsApp.pdb" to "bin\DemoWebFormsApp.pdb"

How to Create the PublishedWebSites folder:

The Visual Studio task is only responsible for the compilation of web application’s binary files, such as .dll and .pdb.  MSBuild arguments are responsible for the publishing of the web application and the creation of the _PublishedWebSite folder with the complete web application.

Add the following argument to the MSBuild argument section in the Visual Studio task: /p:OutDir=$(Build.ArtifactStagingDirectory)

This argument is telling MSBuild to publish the web application from the directory where the web application is compiled (typically in the s directory) to the Build Artifact directory, which is typically in the a folder where the agent is located on the build server.

After the build completes, the Artifacts icon lights up on the build and the _PublishedWebsites folder is now populated with the web application.

image

Only Copy the Contents of the _PublishedWebsites folder to the Artifact drop:

There are a high number of files in the Artifacts folder and not needed for a deployment. Very easy change to the Publish Artifact task by adding the path to the _PublishedWebsites folder in the Artifact Staging directory:

$(build.artifactstagingdirectory)\_PublishedWebsites image

The end result is just the contents of the _PublishedWebsites folder:

image