如果您的网站没有 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>