如何使用某些发布配置文件从命令行发布网站?

时间:2010-08-05 08:19:43

标签: asp.net visual-studio-2010 msbuild

这样的东西

msbuild /t:publish [use PublishProfileName] someproject.csproj

2 个答案:

答案 0 :(得分:23)

msbuild MyProject.csproj /t:PipelinePreDeployCopyAllFilesToOneFolder /p:Configuration=Release;_PackageTempDir=C:\temp\somelocation;AutoParameterizationWebConfigConnectionStrings=false

请参阅MSBuild 2010 - how to publish web app to a specific location (nant)?

对于Visual Studio 2012,您可以使用

msbuild MySolution.sln /p:DeployOnBuild=true;PublishProfile=Production;Password=foo

请参阅ASP.NET Web Deployment using Visual Studio: Command Line Deployment

答案 1 :(得分:3)

这是实现Pavel解决方案的替代解决方案,但在MsBuild文件中使用MsBuild目标:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="build"  
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
        <OutputDirectory>$(DeploymentProject)\bin\$(Configuration)</OutputDirectory>
        <OutputPath>C:\Inetpub\wwwroot</OutputPath>
    </PropertyGroup>
    <Target Name="build">
        <MSBuild 
        Projects="Your Solution File.sln"
        Properties="Configuration=$(Configuration);DeployOnBuild=true;DeployTarget=Package;_PackageTempDir=$(OutputPath);AutoParameterizationWebConfigConnectionStrings=false"
        >
        </MSBuild>
    </Target>
</Project>