Visual Studio 2010 Publish Command from msbuild Command line

Seems like there a bunch of confusion about how to produce the “Publish” behavior provided by Visual Studio 2010 from msbuild 4 command line. The question I keep seeing over and over again is: How do I publsih the output of a web application with web.config tranformations included. This should get the job done:

msbuild solution.sln 
/p:Configuration=Release;DeployOnBuild=true;
DeployTarget=Package;_PackageTempDir=..\publish

Reader interactions

23 Replies to “Visual Studio 2010 Publish Command from msbuild Command line”

  1. How did you find the documentation on this topic? I’m looking for all the different possible values for /p:DeployTarget, /p:MsDeployPublishMethod, etc. and can’t find it andywhere. Where did you find the documentation to know that ‘Package’ was an option for /p:DeployTarget?

    Thanks!

    Reply

  2. I was not able to find any official documentation on those arguments. Basically, I was able to put it together based on examples on stackoverflow and various blog posts. What are you trying to accomplish?

    Reply

  3. Works great for a solution with only one web application. My solution has ~6 class libraries and two WAPs. Any suggestions?

    Reply

  4. For the love of god thank you. This was the most annoying 12 hours getting ccnet configured in my life. This was my last problem. I will now go dance on top of my office building.

    Reply

  5. Frank - the beginner January 13, 2011 at 5:32 pm

    ok so I just want to build my .sln the publish it to a d:\temp_stage directory so I can look at it before I send it to QA.

    do I set PackageTempDir=d:\temp_stage ? or must that be predefined

    Reply

  6. Yes. That should work. Give it a try.

    Reply

  7. Frank - the beginner February 23, 2011 at 2:53 pm

    Hmm sry its been a while getting an error–> MSB4057:The target “PackageTempDir=temp_stage” does not exist in the project..

    But then it gives me the location of the file it is looking at my .csproj file. Your thoughts…. cmd below

    d:\Program Files\Microsoft Visual Studio 10.0\VC>msbuild “D:\StarTeam\Falcon Dia
    lysis\WebSites2010\Davita.FalconDialysis.sln” /p:Configuration=release;DeployOnB
    uild=true;DeployTarget=PackageTempDir=D:\temp_stage

    Reply

  8. Frank - the beginner March 1, 2011 at 3:32 pm

    I got it working however, I have an easier question: Can use msbuild 3.5 to compile a dotnet 4.0 project? Thanks for all your help

    Reply

    1. No. I do not believe so. However, you can use msbuild 4 to target other versions of the .net framework.

      Reply

  9. If you need to “Publish” specific project from solution use this:

    The key is to specify Targets here.

    @Dave

    Reply

  10. Great!!! it is working like a charm… I spent some hours trying to find so nice and simple solution.

    Reply

  11. @Alexey
    This post seems to be missing what we are supposed to use…where exactly do we specify the targets?

    Reply

  12. Hi. I try to do this, but I have several projects on my solution and that deploy just the last one. How can I specific that is to deploy all projects on my solution? Thanks for help

    Reply

  13. I suspect this would work great if I had a target in my project that fits with the ‘DeployTarget=Package’specified in the command line.

    Could you please explain what the target does or give us a link to some documentation.

    Reply

  14. Thank you!

    Reply

  15. If you are going for most excellent contents like myself, only visit this site every day for
    the reason that it gives feature contents, thanks

    Reply

  16. girl chat…

    “[…]Christopher Patterson » Visual Studio 2010 Publish Command from msbuild Command line[…]”…

    Reply

  17. Representing that repair work services will be completed by a particular day in orrder tto induce the sale, then failing to have
    the repair service solutions finished byy that day.

    Reply

  18. This page truly has all the information I wanted concerning this subject
    and didn’t know who to ask.

    Reply

  19. Chiropractors In Santa Monica…

    Christopher Patterson » Visual Studio 2010 Publish Command from msbuild Command line…

    Reply

  20. Quality articles or reviews is the crucial to
    attract the viewers to visit the web site, that’s
    what this site is providing.

    dig this (Josh)
    http://luchorosarigasino.blogspot.com

    Reply

  21. I do not know if it’s just me or if perhaps everyone else encountering issues with your site.

    It seems like some of the text on your posts are running off the screen. Can someone
    else please comment and let me know if this is happening to them as well?
    This might be a issue with my internet browser because I’ve had this happen before.
    Kudos

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *