【问题标题】:publish a website through MSBuild通过 MSBuild 发布网站
【发布时间】:2014-08-07 06:33:23
【问题描述】:

我正在尝试在命令提示符下通过 msbuild 发布一个 asp.net 网站,但没有成功。

我尝试创建一个新的 Web 应用程序并执行以下命令,它可以工作。

C:\Windows\system32>msbuild.exe "C:\VisualStudio 2012\Projects\HelloWorldSample\HelloWorldSample\HelloWorld\HelloWorldSample.csproj" /p:DeployOnBuild=true /p:PublishProfile="HelloDeploy"

但我的问题是,在网站上我没有 .csproj 文件。这就是为什么我无法为此执行上述命令的原因。

所以请任何人帮助我如何为网站进行部署。

谢谢。

【问题讨论】:

标签: web-deployment msdeploy


【解决方案1】:

如果您的网站没有 csproj 项目文件,则很可能是一个仅包含您的网站文件的目录。 You can convert it to a Web Application(从而得到一个csproj文件)或者直接使用msdeploy生成一个可部署的包,然后使用msdeploy部署到你的网站。当您运行 msbuild /p:DeployOnBuild

时,这实际上会发生在幕后

创建一个 msdeploy 可部署网站you can use the following snippet

msdeploy.exe 
  -verb:sync 
  -source:iisApp="C:\development\mywebsite\the-website-dir" 
  -dest:package="C:\temp\mywebsite-package.zip" 
  -declareParamFile:"C:\development\mywebsite\parameters.xml" 

您需要在parameters.xml 文件中为站点名称创建一个参数,该文件将与压缩的网站项目一起打包

<?xml version="1.0" encoding="utf-8" ?>
<parameters>
<!-- 
This file contains (among others) references to web.config fields (xpath) 
which will be 'parameterized' on package before deploy. The actual values will then be filled in based on the given deploy environment.
-->
  <parameter name="IIS Web Application Name" tags="IisApp">
    <parameterEntry kind="ProviderPath" scope="iisApp" match="" tags="IisApp" />
  </parameter> 
</parameters>

这将生成一个可部署的 msdeploy 包,您可以使用以下方法将其上传到 IIS:

msdeploy.exe -source:package=c:\temp\mywebsite-package.zip -dest:auto,computerName=https://mysite.example.com:8172/MsDeploy.axd,userName=USERNAME,password=PASSWORD,authtype=Basic, -verb:sync -disableLink:AppPoolExtension -disableLink:ContentExtension -disableLink:CertificateExtension -setParamFile:example-setParameters.xml -allowUntrusted

连同一个setParameter文件

<?xml version="1.0" encoding="utf-8" ?>
<parameters>
  <setParameter name="IIS Web Application Name" value="mysite.example.com" />
</parameters>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-29
    • 2019-08-12
    • 1970-01-01
    相关资源
    最近更新 更多