我正在尝试在构建脚本中复制 Visual Studio 2008 中此对话的确切功能:
这是一个 ASP.NET 网站站点,而不是网络应用程序。
我在 Google 上搜索了这个问题,发现了很多涉及 MSBuild 的内容,但这一切似乎都与 ASP.NET Web 应用程序的解决方案有关:
http://www.driebier.net/post/Using-MSBuild-to-deploy-visual-studio-2005-web-applications.aspx http://blog.donnfelker.com/post/TFS-Build-Not-Publishing-Web-Applications.aspx
This article似乎与 ASP.NET 网站相关,但我发现在尝试使用这些建议进行构建时遇到错误:
C:\dev\T&A>msbuild /t:_CopyWebApplication /property:OutDir=c:\temp\taweb\ /prope rty:WebProjectOutputDir=c:\temp\taweb\ Microsoft (R) Build Engine Version 3.5.30729.1 [Microsoft .NET Framework, Version 2.0.50727.3074] Copyright (C) Microsoft Corporation 2007. All rights reserved. Build started 22/04/2009 11:50:42. Project "C:\dev\T&A\TAWeb.sln" on node 0 (_CopyWebApplication target(s)). Building solution configuration "Debug|.NET". C:\dev\T&A\TAWeb.sln : error MSB4057: The target "_CopyWebApplication" does not exist in the project. Done Building Project "C:\dev\T&A\TAWeb.sln" (_CopyWebApplication target(s)) -- FAILED. Build FAILED. "C:\dev\T&A\TAWeb.sln" (_CopyWebApplication target) (1) -> C:\dev\T&A\TAWeb.sln : error MSB4057: The target "_CopyWebApplication" does n ot exist in the project. 0 Warning(s) 1 Error(s) Time Elapsed 00:00:00.06
我尝试发布的解决方案(继承的,不是我自己的)没有 .csproj 文件(我可以在其中从 C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v9 导入 _CopyWebApplication 目标.0\WebApplications\Microsoft.WebApplication.targets)
也许这是 Visual Studio 2005/2008 的区别?
无论如何,我觉得我走错了路。
本质上,我只需要完全实现上述对话的功能,但是是从命令行实现。
非常感谢
最佳答案
以下命令使用默认设置复制发布网站对话框。
使用默认设置发布网站的命令
aspnet_compiler -nologo -v/-p "C:\WebSite1"-u "C:\TargetPath"
引用
1) 请参阅标题为您想要发布网站但没有 Visual Studio 的社区内容,然后...,地址:http://msdn.microsoft.com/en-us/library/20yh9f1b(classic).aspx .
- Microsoft Visual Studio 2005 > Visual Studio 2005 命令提示符
- Microsoft Visual Studio 2008 > Visual Studio 2008 命令提示符
- Microsoft .NET Framework SDK v2.0 > SDK 命令提示符
2) 请参阅“ASP.NET 编译工具 (Aspnet_compiler.exe)”,地址:http://msdn.microsoft.com/en-us/library/ms229863.aspx .
3) 以下摘录自演练:使用 XCOPY 部署 ASP.NET Web 应用程序,地址:http://msdn.microsoft.com/en-us/library/f735abw9.aspx
As an alternative to using the XCOPY command-line tool, which is supported by all versions of the .NET Framework, you can use the new .NET Framework 2.0 tool located at %SystemRoot%\Microsoft.NET\Framework\version 2 or later\Aspnet_compiler.exe to compile and deploy your Web application. For more information, see ASP.NET Compilation Tool (Aspnet_compiler.exe).
4) 以下摘录自如何:预编译 ASP.NET 网站以进行部署,地址:http://msdn.microsoft.com/en-us/library/ms227976.aspx .
If your Web site is not an Internet Information Services (IIS) application and therefore has no entry in the IIS metabase, used the following value for the -v switch.
aspnet_compiler -p physicalOrRelativePath -v / targetPath
In this case, the physicalOrRelativePath parameter refers to the fully qualified directory path in which the Web site files are located, or a path relative to the current directory. The period (.) operator is allowed in the physicalOrRelativePath parameter. The -v switch specifies a root that the compiler will use to resolve application-root references (for example, with the tilde (~) operator). When you specify the value of / for the -v switch the compiler will resolve the paths using the physical path as the root.
关于asp.net - 从命令行复制 VS2008 "Publish Web Site",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/776635/