2010-08-05 35 views

Trả lời

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

Xem MSBuild 2010 - how to publish web app to a specific location (nant)?

Đối với Visual Studio 2012, bạn có thể sử dụng

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

Xem ASP.NET Web Deployment using Visual Studio: Command Line Deployment

+0

web.config của tôi kết thúc như thế này sau khi chạy lệnh rằng msbuild: \t

+0

@Jhonny Bạn cần tham số AutoParameterizationWebConfigConnectionStrings, tôi đã cập nhật câu trả lời của mình. –

+0

Nó làm việc tốt cho tôi, cảm ơn bạn rất nhiều !! –

3

Đây là một giải pháp thay thế để đạt được giải pháp Pavel nhưng sử dụng MSBuild mục tiêu trong một tập tin 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> 
Các vấn đề liên quan