用VS 2005生成
在工具条上,从“解决方案配置(Solution Configurations)”中选择“发布(Release)”。这将发布当前的解决方案配置。然后,在“生成(Build)”菜单,选择“生成解决方案(Build Solution)”。
在“输出窗口(Output window)”将显示生成输出。下面的例子展示了生成的输出信息。注意,在这个例子中,生成(build)的是Web Deployment项目,而没有生成(build)Web站点项目。
------ Skipped Build: Project: c:/.../MyWeb/, Configuration: Debug .NET ------
Project not selected to build for this solution configuration
------ Build started: Project: MyWeb_deploy, Configuration: Release Any CPU ------
Build started 11/7/2005 9:40:09 AM.
Target AspNetCompiler:
C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/aspnet_compiler.exe –
v /MyWeb -p c:/MyProjects/MyWeb/MyWeb -u -f
c:/MyProjects/MyWeb/MyWeb_deploy/Release/
Updateing web.config compilation debug = 'False' ...
Successfully updated web.config compilation debug = 'False' ...
Removing directory "c:/MyProjects/MyWeb/MyWeb_deploy/Release//App_Data".
Target GenerateAssemblyInfo:
Generating AssemblyInfo ...
Setting [assembly: AssemblyFileVersion("2.0.0.0")]
Setting [assembly: AssemblyVersion("2.0.0.0")]
Successfully Generated AssebmlyInfo ...
C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Csc.exe
/out:c:/MyProjects/MyWeb/MyWeb_deploy/AssemblyInfo/Release/AssemblyInfo
.dll /target:library
c:/MyProjects/MyWeb/MyWeb_deploy/AssemblyInfo/Release/AssemblyInfo.cs
Target AspNetMerge:
Running aspnet_merge.exe ...
C:/Program Files/MSBuild/Microsoft/WebDeployment/v8.0/aspnet_merge.exe
c:/MyProjects/MyWeb/MyWeb_deploy/Release -o MyCompany.MyWeb -copyattrs
c:/MyProjects/MyWeb/MyWeb_deploy/AssemblyInfo/Release/AssemblyInfo.dll
Successfully merged 'c:/MyProjects/MyWeb/MyWeb_deploy/Release'.
Target ReplaceWebConfigSections:
Updating web.config: RootPath =
c:/MyProjects/MyWeb/MyWeb_deploy/Release/, ValidateSections = False,
UseExternalConfigSource = True
Replacing section connectionStrings with file release.config
Update of web.config Succeeded.
Target CreateVirtualDirectory:
Initializing IIS Web Server...
Successfully created virtual directory 'MyWeb_Release'.
Granting IIS read access to the folder 'c:/MyProjects/MyWeb/MyWeb_deploy/Release'...
Grant folder access successful.
Not setting IIS access to folder
'c:/MyProjects/MyWeb/MyWeb_deploy/Release/App_Data'. Folder does not exist.
Build succeeded.
Time Elapsed 00:00:11.52
========== Build: 1 succeeded or up-to-date, 0 failed, 1 skipped ==========
若想控制MSBuild生成的信息量,可以从“工具(Tools)”菜单,选择“选项(Options)”。再选择“项目和解决方案(Projects and Solutions)”,在“生成和运行(Build and Run)”下,可以规定MSBuild输出的信息量等级,包括“不输出(Quiet)”,“最小(Minimal)”,“正常(Normal)”,“详细(Detailed)”和“诊断(Diagnostic)”。
通过MSBuild命令行生成
在命令行下,通过msbuild.exe命令,生成解决方案或是.wdproj文件。如下所示,其中,选项“-p”规定生成的配置。
C:/MyProjects/MyWeb>msbuild MyWeb.sln /p:Configuration=Release
生成的输出如下所示:
Microsoft (R) Build Engine Version 2.0.50727.42
[Microsoft .NET Framework, Version 2.0.50727.42]
Copyright (C) Microsoft Corporation 2005. All rights reserved.
Build started 11/7/2005 10:01:05 AM.
__________________________________________________
Project "C:/MyProjects/MyWeb/MyWeb.sln" (default targets):
Target ValidateSolutionConfiguration:
Building solution configuration "Release|Mixed Platforms".
Target Build:
Target MyWeb_deploy:
__________________________________________________
Project "C:/MyProjects/MyWeb/MyWeb.sln" is building
"C:/MyProjects/MyWeb/MyWeb_deploy/MyWeb_deploy.wdproj" (default
targets):
Target AspNetCompiler:
C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/aspnet_compiler.exe -v
/MyWeb -p C:/MyProjects/MyWeb/MyWeb -u -f
C:/MyProjects/MyWeb/MyWeb_deploy/Release/
Updateing web.config compilation debug = 'False' ...
Successfully updated web.config compilation debug = 'False' ...
Removing directory
"C:/MyProjects/MyWeb/MyWeb_deploy/Release//App_Data".
Target GenerateAssemblyInfo:
Generating AssemblyInfo ...
Setting [assembly: AssemblyFileVersion("2.0.0.0")]
Setting [assembly: AssemblyVersion("2.0.0.0")]
Successfully Generated AssebmlyInfo ...
C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/Csc.exe
/out:C:/MyProjects/MyWeb/MyWeb_deploy/AssemblyInfo/Release/AssemblyInfo.dll /target:library
C:/MyProjects/MyWeb/MyWeb_deploy/AssemblyInfo/Release/AssemblyInfo.cs
Target AspNetMerge:
Running aspnet_merge.exe ...
C:/Program
Files/MSBuild/Microsoft/WebDeployment/v8.0/aspnet_merge.exe
C:/MyProjects/MyWeb/MyWeb_deploy/Release -o MyCompany.MyWeb -copyattrs
C:/MyProjects/MyWeb/MyWeb_deploy/AssemblyInfo/Release/AssemblyInfo.dll
Successfully merged
'C:/MyProjects/MyWeb/MyWeb_deploy/Release'.
Target ReplaceWebConfigSections:
Updating web.config: RootPath =
C:/MyProjects/MyWeb/MyWeb_deploy/Release/, ValidateSections = False,
UseExternalConfigSource = True
Replacing section connectionStrings with file
release.config
Update of web.config Succeeded.
Target CreateVirtualDirectory:
Initializing IIS Web Server...
Successfully created virtual directory 'MyWeb_Release'.
Granting IIS read access to the folder
'C:/MyProjects/MyWeb/MyWeb_deploy/Release'...
Grant folder access successful.
Not setting IIS access to folder
'C:/MyProjects/MyWeb/MyWeb_deploy/Release/App_Data'. Folder does not
exist.
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:14.13
生成(build)产生的文件位于 MyWeb_deploy/Release 文件夹。注意:输出到一个程序集MyCompany.MyWeb.dll。
位置 |
文件 |
C:/MyProjects/MyWeb/MyWeb_deploy/Release |
Default.aspx PrecompiledApp.config release.config web.config |
C:/MyProjects/MyWeb/MyWeb_deploy/Release/bin |
App_Code.compiled |