Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 885855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T12:58:35+00:00 2026-05-15T12:58:35+00:00

Visual Studio 2010 has a Publish command that allows you to publish your Web

  • 0

Visual Studio 2010 has a Publish command that allows you to publish your Web Application Project to a file system location. I’d like to do this on my TeamCity build server, so I need to do it with the solution runner or msbuild. I tried using the Publish target, but I think that might be for ClickOnce:

msbuild Project.csproj /t:Publish /p:Configuration=Deploy

I basically want to do exactly what a web deployment project does, but without the add-in. I need it to compile the WAP, remove any files unnecessary for execution, perform any web.config transformations, and copy the output to a specified location.

My Solution, based on Jeff Siver’s answer

<Target Name="Deploy">
    <MSBuild Projects="$(SolutionFile)" 
             Properties="Configuration=$(Configuration);DeployOnBuild=true;DeployTarget=Package" 
             ContinueOnError="false" />
    <Exec Command="&quot;$(ProjectPath)\obj\$(Configuration)\Package\$(ProjectName).deploy.cmd&quot; /y /m:$(DeployServer) -enableRule:DoNotDeleteRule" 
          ContinueOnError="false" />
</Target>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T12:58:35+00:00Added an answer on May 15, 2026 at 12:58 pm

    I got it mostly working without a custom msbuild script. Here are the relevant TeamCity build configuration settings:

    Artifact paths: %system.teamcity.build.workingDir%\MyProject\obj\Debug\Package\PackageTmp 
    Type of runner: MSBuild (Runner for MSBuild files) 
    Build file path: MyProject\MyProject.csproj 
    Working directory: same as checkout directory 
    MSBuild version: Microsoft .NET Framework 4.0 
    MSBuild ToolsVersion: 4.0 
    Run platform: x86 
    Targets: Package 
    Command line parameters to MSBuild.exe: /p:Configuration=Debug
    

    This will compile, package (with web.config transformation), and save the output as artifacts. The only thing missing is copying the output to a specified location, but that could be done either in another TeamCity build configuration with an artifact dependency or with an msbuild script.

    Update

    Here is an msbuild script that will compile, package (with web.config transformation), and copy the output to my staging server

    <?xml version="1.0" encoding="utf-8" ?>
    <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
            <SolutionName>MySolution</SolutionName>
            <SolutionFile>$(SolutionName).sln</SolutionFile>
            <ProjectName>MyProject</ProjectName>
            <ProjectFile>$(ProjectName)\$(ProjectName).csproj</ProjectFile>
        </PropertyGroup>
    
        <Target Name="Build" DependsOnTargets="BuildPackage;CopyOutput" />
    
        <Target Name="BuildPackage">
            <MSBuild Projects="$(SolutionFile)" ContinueOnError="false" Targets="Rebuild" Properties="Configuration=$(Configuration)" />
            <MSBuild Projects="$(ProjectFile)" ContinueOnError="false" Targets="Package" Properties="Configuration=$(Configuration)" />
        </Target>
    
        <Target Name="CopyOutput">
            <ItemGroup>
                <PackagedFiles Include="$(ProjectName)\obj\$(Configuration)\Package\PackageTmp\**\*.*"/>
            </ItemGroup>
            <Copy SourceFiles="@(PackagedFiles)" DestinationFiles="@(PackagedFiles->'\\build02\wwwroot\$(ProjectName)\$(Configuration)\%(RecursiveDir)%(Filename)%(Extension)')"/>
        </Target>
    </Project>
    

    You can also remove the SolutionName and ProjectName properties from the PropertyGroup tag and pass them to msbuild.

    msbuild build.xml /p:Configuration=Deploy;SolutionName=MySolution;ProjectName=MyProject
    

    Update 2

    Since this question still gets a good deal of traffic, I thought it was worth updating my answer with my current script that uses Web Deploy (also known as MSDeploy).

    <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
        <ProjectFile Condition=" '$(ProjectFile)' == '' ">$(ProjectName)\$(ProjectName).csproj</ProjectFile>
        <DeployServiceUrl Condition=" '$(DeployServiceUrl)' == '' ">http://staging-server/MSDeployAgentService</DeployServiceUrl>
      </PropertyGroup>
    
      <Target Name="VerifyProperties">
        <!-- Verify that we have values for all required properties -->
        <Error Condition=" '$(ProjectName)' == '' " Text="ProjectName is required." />
      </Target>
    
      <Target Name="Build" DependsOnTargets="VerifyProperties">
        <!-- Deploy using windows authentication -->
        <MSBuild Projects="$(ProjectFile)"
                 Properties="Configuration=$(Configuration);
                                 MvcBuildViews=False;
                                 DeployOnBuild=true;
                                 DeployTarget=MSDeployPublish;
                                 CreatePackageOnPublish=True;
                                 AllowUntrustedCertificate=True;
                                 MSDeployPublishMethod=RemoteAgent;
                                 MsDeployServiceUrl=$(DeployServiceUrl);
                                 SkipExtraFilesOnServer=True;
                                 UserName=;
                                 Password=;"
                 ContinueOnError="false" />
      </Target>
    </Project>
    

    In TeamCity, I have parameters named env.Configuration, env.ProjectName and env.DeployServiceUrl. The MSBuild runner has the build file path and the parameters are passed automagically (you don’t have to specify them in Command line parameters).

    You can also run it from the command line:

    msbuild build.xml /p:Configuration=Staging;ProjectName=MyProject;DeployServiceUrl=http://staging-server/MSDeployAgentService
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.