复制VS2008“发布网站"从命令行 [英] Replicate VS2008 "Publish Web Site" from command line

查看:20
本文介绍了复制VS2008“发布网站"从命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Visual Studio 2008 的构建脚本中复制此对话的确切功能:

这是一个 ASP.NET Web 站点,而不是一个 Web 应用程序.

我在谷歌上搜索了很多涉及 MSBuild 的东西,但这似乎都与作为 ASP.NET Web 应用程序布局的解决方案有关:

http:///www.driebier.net/post/Using-MSBuild-to-deploy-visual-studio-2005-web-applications.aspxhttp://blog.donnfelker.com/post/TFS-Build-Not-Publishing-Web-Applications.aspx

这篇文章 似乎与 ASP.NET 网站有关,但我发现尝试使用这些建议进行构建时出现错误:

<前>C:devT&A>msbuild/t:_CopyWebApplication/property:OutDir=c: emp aweb/property:WebProjectOutputDir=c: emp awebMicrosoft (R) 构建引擎版本 3.5.30729.1[Microsoft .NET Framework,版本 2.0.50727.3074]版权所有 (C) Microsoft Corporation 2007.保留所有权利.构建于 22/04/2009 11:50:42 开始.节点 0(_CopyWebApplication 目标)上的项目C:devT&ATAWeb.sln".构建解决方案配置Debug|.NET".C:devT&ATAWeb.sln:错误 MSB4057:目标_CopyWebApplication"没有存在于项目中.完成构建项目 "C:devT&ATAWeb.sln" (_CopyWebApplication target(s)) --失败的.构建失败."C:devT&ATAWeb.sln" (_CopyWebApplication 目标) (1) ->C:devT&ATAWeb.sln:错误 MSB4057:目标_CopyWebApplication"不项目中不存在.0 警告1 错误已用时间 00:00:00.06

我尝试发布的解决方案(继承的,不是我自己的)没有 .csproj 文件(我可以在其中从 C:Program Files (x86)MSBuildMicrosoftVisualStudiov9 导入 _CopyWebApplication 目标.0WebApplicationsMicrosoft.WebApplication.targets)

也许这是 Visual Studio 2005/2008 的区别?

无论如何,我觉得我在那里走错了路.

本质上,我只需要完全实现上述对话的功能,但需要从命令行实现.

非常感谢

解决方案

以下命令使用默认设置复制发布网站对话框.

使用默认设置发布网站的命令

aspnet_compiler -nologo -v/-p "C:WebSite1" -u "C:TargetPath"

参考

1) 在 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

<块引用>

作为使用 XCOPY 的替代方法支持的命令行工具.NET Framework 的所有版本,您可以使用新的 .NET Framework 2.0工具位于%SystemRoot%Microsoft.NETFramework版本2 或更高版本Aspnet_compiler.exe 到编译和部署您的 Web应用.有关详细信息,请参阅 ASP.NET 编译工具 (Aspnet_compiler.exe).

4) 以下摘自 How to: Precompile ASP.NET Web Sites for Deployment,位于 http://msdn.microsoft.com/en-us/library/ms227976.aspx.

<块引用>

如果您的网站不是 Internet信息服务 (IIS) 应用程序因此在 IIS 中没有条目元数据库,使用以下值-v 开关.

<代码>aspnet_compiler -p物理或相对路径 -v/目标路径

在这种情况下,physicalOrRelativePath 参数指的是完全合格的网站所在的目录路径文件所在的位置,或相对路径到当前目录.时期(.) 运算符在physicalOrRelativePath 参数.这-v 开关指定编译器将用于解析的根应用程序根引用(对于例如,使用波浪号 (~) 运算符).当您指定/的值时-v 开关编译器将使用物理解析路径路径作为根.

I am trying to replicate the exact functionality of this dialogue in Visual Studio 2008 in a build script:

This is an ASP.NET web site, not a web application.

I have Googled around this and turned up quite a bit of stuff involving MSBuild, but this all seems to concern solutions laid out as ASP.NET Web Applications:

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 seems to be relevant to ASP.NET Web Sites, but I find that I'm getting an error when trying to build using those suggestions:

C:devT&A>msbuild /t:_CopyWebApplication /property:OutDir=c:	emp	aweb /prope
rty:WebProjectOutputDir=c:	emp	aweb

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:devT&ATAWeb.sln" on node 0 (_CopyWebApplication target(s)).
  Building solution configuration "Debug|.NET".
C:devT&ATAWeb.sln : error MSB4057: The target "_CopyWebApplication" does not
 exist in the project.
Done Building Project "C:devT&ATAWeb.sln" (_CopyWebApplication target(s)) --
 FAILED.


Build FAILED.

"C:devT&ATAWeb.sln" (_CopyWebApplication target) (1) ->
  C:devT&ATAWeb.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

The solution I'm trying to publish (inherited, not my own) doesn't have .csproj files (where I could import the _CopyWebApplication target from C:Program Files (x86)MSBuildMicrosoftVisualStudiov9.0WebApplicationsMicrosoft.WebApplication.targets)

Perhaps this is a Visual Studio 2005/2008 difference?

Anyway, I feel that I'm going down the wrong path there.

Essentially I just need to achieve exactly what the above dialogue does, but from the command line.

Thanks very much

解决方案

The following command duplicates the Publish Web Site dialog with default settings.

Command for Publish Web Site with Default Settings

aspnet_compiler -nologo -v / -p "C:WebSite1" -u "C:TargetPath"

Reference

1) See Community Content titled You want Publish a site but you have not Visual Studio then... at http://msdn.microsoft.com/en-us/library/20yh9f1b(classic).aspx.

  • Microsoft Visual Studio 2005 > Visual Studio 2005 Command Prompt
  • Microsoft Visual Studio 2008 > Visual Studio 2008 Command Prompt
  • Microsoft .NET Framework SDK v2.0 > SDK Command Prompt

2) See "ASP.NET Compilation Tool (Aspnet_compiler.exe)" at http://msdn.microsoft.com/en-us/library/ms229863.aspx.

3) Following excerpt from Walkthrough: Deploying an ASP.NET Web Application Using XCOPY at 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.NETFrameworkversion 2 or laterAspnet_compiler.exe to compile and deploy your Web application. For more information, see ASP.NET Compilation Tool (Aspnet_compiler.exe).

4) Following excerpt from How to: Precompile ASP.NET Web Sites for Deployment at 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.

这篇关于复制VS2008“发布网站"从命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆