2008-11-18 25 views
10

Trong Visual Studio 2008 nếu bạn có một dự án web, bạn có thể sử dụng menu Build -> Publish Web.
Tôi có thể đạt được kết quả tương tự với msbuild qua dòng lệnh không?Làm thế nào để xuất bản một dự án web với MSBuild?


Tìm thấy câu trả lời trong bài đăng trên blog này: How to publish a web site with MSBuild.
Cụ thể hơn là ở đây: Using MSBuild to deploy visual studio 2005 web applications.

Trả lời

2

Tôi nghĩ rằng những gì bạn muốn sử dụng là aspnet_compliler

C:\Program Files\Microsoft Visual Studio 9.0\VC>aspnet_compiler -? 
Utility to precompile an ASP.NET application 
Copyright (C) Microsoft Corporation. All rights reserved. 

Usage: 
aspnet_compiler [-?] [-m metabasePath | -v virtualPath [-p physicalDir]] 
       [[-u] [-f] [-d] [-fixednames] targetDir] [-c] 
       [[-keyfile file | -keycontainer container] 
        [-aptca] [-delaySign]] 
       [-errorstack] 

-?   Prints this help text. 
-m   The full IIS metabase path of the application. This switch cannot 
       be combined with the -v or -p switches. 
-v   The virtual path of the application to be compiled (e.g. 
       "/MyApp"). If -p is specified, the physical path is used to 
       locate the application. Otherwise, the IIS metabase is used, and 
       the application is assumed to be in the default site (under 
       "/LM/W3SVC/1/Root"). This switch cannot be combined with the -m 
       switch. 
-p   The physical path of the application to be compiled. If -p is 
       missing, the IIS metabase is used to locate the app. This switch 
       must be combined with -v. 
-u   If specified, the precompiled application is updatable. 
-f   Overwrites the target directory if it already exists. Existing 
       contents are lost. 
-d   If specified, the debug information is emitted during 
       compilation. 
targetDir  The physical path to which the application is compiled. If not 
       specified, the application is precompiled in-place. 
-c   If specified, the precompiled application is fully rebuilt. Any 
       previously compiled components will be re-compiled. This option 
       is always enabled when targetDir is specified. 
-keyfile  The physical path to the strong name key file. 
-keycontainer Specifies a strong name key container. 
-aptca  If specified, the strong-name assembly will allow partially 
       trusted callers. 
-delaysign If specified, the assembly is not fully signed when created. 
-fixednames If specified, the compiled assemblies will be given fixed names. 
-nologo  Suppress compiler copyright message. 
-errorstack Shows extra debugging information that can help debug certain 
       conditions. 

Examples: 

The following two commands are equivalent, and rely on the IIS metabase. The 
compiled application is deployed to c:\MyTarget: 
    aspnet_compiler -m /LM/W3SVC/1/Root/MyApp c:\MyTarget 
    aspnet_compiler -v /MyApp c:\MyTarget 

The following command compiles the application /MyApp in-place. The effect is 
that no more compilations will be needed when HTTP requests are sent to it: 
    aspnet_compiler -v /MyApp 

The following command does *not* rely on the IIS metabase, as it explicitly 
specifies the physical source directory of the application: 
    aspnet_compiler -v /MyApp -p c:\myapp c:\MyTarget 
+0

Không, tôi cần phải làm điều đó trên máy xây dựng mà không có VisualStudio, chỉ msbuild. –

+0

Không phải là vấn đề - aspnet_compiler.exe nên được cài đặt với SDK, vì vậy bạn sẽ có nó trên máy xây dựng của mình. – Shog9

+0

Vẫn không giống nhau - nó không xây dựng tất cả các phụ thuộc. –

Các vấn đề liên quan