Search code examples
tfsmsbuildweb-deploymentmsdeployrelease-management

TFS Build Definition - Deploy only files needed to run this application


I am setting up TFS 2015 for Build and deploy. I have got things working as I expect however I started to notice that the files being published in TFS do not look like the same files that were being published when I right-click and publich the project in Visual Studio (i.e. in VS my publication doesnt contain the .cs files etc..).

In TFS I have Build Steps:

  • Visual Studio Build enter image description here

  • Copy Files (to copy the build files to a staging directory) enter image description here

  • Publish Build Artifacts (going to File Share location I will then deploy from) enter image description here

I was rather hoping to see Web-Deploy/MSDeploy in the list of Build Steps (under Deploy).

Has anyone come across this and figured out what is going on? Please let me know if you need any more detail on my current configuration.

Thanks

**** EDIT ****

Okay, I have been learning a lot more about what I am expecting to see and it seems like I need my build to go through a PreCompile. From what i have read the project I am currently workign on is a WAP and is therefore precompiled as part of every publication. This moves the code (.cs files) into respective DLLs.

I have therefore started looking down the route of applying a Batch Script to initiate the ASP.NETs aspnet_compiler.exe to carry out the precompilation - but I am getting various errors relating to the web.config.

This is starting to become quite a pain for something I might expect to be quite simple for TFS Build..!! It is Microsoft afterall!


Solution

  • In vNext build, to publish your build artifacts with the Copy files and Publish build artifacts steps. Try to use the local path on the agent where any artifacts are copied to before being pushed to their destination. For example:

    1. Add /p:DeployOnBuild=true /p:OutDir="$(build.artifactstagingdirectory)\" arguments in Visual Studio Build step;
    2. Change "Path to Publish" of Publish Build Artifacts task to $(build.artifactstagingdirectory)\_PublishedWebsites\ProjectName: