我在MSBuild脚本中有以下任务,使用Web Deploy(MSDeploy服务)部署到远程服务器:
<Target Name="Deploy">
<MSBuild
Projects="$(SolutionFile)"
Properties="Configuration=Release; DeployOnBuild=True;
DeployTarget=MsDeployPublish; MSDeployPublishMethod=WMSvc;
MsDeployServiceUrl=$(DeployServiceUrl);
DeployIisAppPath=$(DeployIisAppPath);
UserName=$(DeployUserName); Password=$(DeployPassword);
CreatePackageOnPublish=True; AllowUntrustedCertificate=True" />
</Target>
Run Code Online (Sandbox Code Playgroud)
它工作正常.但是,我想在部署应用程序之前放置app_offline.htm文件(在远程服务器上),并在部署之后删除app_offline.htm文件(或出错时).是否有MSBuild属性或任何其他脚本调整才能实现?
提前致谢.
我试图在MSDeploy中使用-presync:runCommand选项,无论我尝试运行什么,我都会收到相同的错误:
错误:客户端未保留所需的权限.
我已经尝试了一些项目来执行,但它们都没有工作.理想情况下,我想在服务器上执行exe:
-presync:runCommand=C:\MyExecutable.exe,dontUseCommandExe=true
Run Code Online (Sandbox Code Playgroud)
我也试过了
-presync:runCommand=C:\TestScript.bat
Run Code Online (Sandbox Code Playgroud)
并从他们的文档中提取样本
-presync:runCommand="net stop w3svc"
Run Code Online (Sandbox Code Playgroud)
提前致谢.
当我为webapp构建部署包时,该包包含一个archive.xml文件,其中包含以下内容:
<createApp
applicationPool=""
MSDeploy.applicationPool="1"
appExists="True"
MSDeploy.appExists="1"
... />
Run Code Online (Sandbox Code Playgroud)
如何控制安装webapp的应用程序池,并在某些情况下创建新的应用程序池?是否有VS设置我可以更改以控制上述输出或以其他方式影响应用程序池在部署时的方式?
根据一篇SO帖子,我可以通过添加以下选项告诉msbuild使用应用程序池,但我看不出生成的输出有任何区别:
/p:IncludeAppPool=true
Run Code Online (Sandbox Code Playgroud)
关于为msdeploy设置应用程序池的另一篇文章似乎暗示我可能能够修改生成的parameters.xml
文件,以便我可以将应用程序池名称指定为msdeploy的参数.此文件存在于zip包中,因此不容易自定义.如果我将其更改为存档,则文件更容易访问.
该HOWTO部署web应用程序页面似乎暗示我可能需要从IIS快速切换到IIS,然后再启用一些复选框.在我的项目属性页面上,Include application pool settings used by this Web project
无论"在IIS Express中配置了包含IIS设置"复选框设置(我目前尚未选中),都会禁用该复选框.我将尝试切换到下一个完整的IIS,看看是否能让我更好地控制.
看起来我可以用一个单独的工具创建一个应用程序池,但我不确定它是否只是TFS.这是我以前从未见过的工具,但它可能是一个功能强大的工具.
MSDeploy的appPoolConfig提供程序看起来很有前途,因为我可以手动设置一个应用程序池,然后将其用作同步源,但至少它只是手动一次.
当我尝试使用MSDeploy从开发人员命令提示符将站点部署到我的localhost时,我一直收到错误"Error_Connection_Terminated",并且我在我的绳子末端试图弄清楚是什么导致它,错误是非常模糊的问题实际上是.我已正确设置部署文件夹的权限,并且已在服务窗口中多次重新启动Web部署代理服务.我已经在网上发布了许多解决方案,但没有用,因为它们都没有处理使用开发人员命令提示符,而只是通过使用visual studio本身提供解决方案.
任何有MSDeploy或IIS经验的人都能够解决这个问题或提出如何解决这个问题的建议.
错误状态"Error_Connection_Terminated错误:发生了意外的文件结束.以下元素未关闭:结果.第1行,第550位.错误计数:1."
我们正在使用msdeploy(或Web部署,如果您愿意)打包和部署Web应用程序.通过声明参数包时间,我们可以在部署时提供值(以替换连接字符串等).
我们目前面临的问题是替换我们的Web配置中的applicationSettings部分中的值.我们不能让msdeploy替换值,因为我们要替换的内容是xml元素中的文本,而不是属性值(我们得到的警告是:"无法在节点类型'Element'上设置值").
相关配置如下所示:
<applicationSettings>
<Name.Of.Assembly.Properties.Settings>
<setting name="someSetting" serializeAs="String">
<value>I wanna be replaced</value>
</setting>
</Name.Of.Assembly.Properties.Settings>
</applicationSettings>
Run Code Online (Sandbox Code Playgroud)
而declare参数xml如下所示:
<parameter name="XX" defaultValue="default">
<parameterEntry kind="XmlFile"
scope="Web\.config$"
match="/configuration/applicationSettings/Name.Of.Assembly.Properties.Settings/setting[@name='someSetting']/value" />
</parameter>
Run Code Online (Sandbox Code Playgroud)
msdeploy只支持替换属性值还是我做错了什么?
以前发布我的web api应用程序工作得很好.今天我将我的应用程序从"任何cpu"转换为x86.现在当我发布它添加一个连接字符串到Web配置,这导致我的应用程序失败.起初我虽然我可能会意外地添加一些东西到web.config转换文件,但不,我没有.这是我的转换文件:
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!--
In the example below, the "SetAttributes" transform will change the value of
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
finds an attribute "name" that has a value of "MyDB".
<connectionStrings>
<add name="MyDB"
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
</connectionStrings>
-->
<entityFramework xdt:Transform="Replace">
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="Server=MyWebServer;Database=RunLog;Trusted_Connection=True; MultipleActiveResultSets=True" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
<system.web>
<compilation xdt:Transform="RemoveAttributes(debug)" />
<!--
In the example below, the "Replace" transform will replace the entire
<customErrors> section of your …
Run Code Online (Sandbox Code Playgroud) 我已经找到了如何设置应用程序池和默认值
<parameter name="applicationPool" defaultValue="MyDefaultValue" >
<parameterEntry kind="DeploymentObjectAttribute" scope="application"
match="application/@applicationPool" />
</parameter>
Run Code Online (Sandbox Code Playgroud)
有谁知道如何设置"IIS Web应用程序名称"?它在SetParameters.xml文件中生成为
<setParameter name="IIS Web Application Name" value="Default Web Site/MySite_deploy" />
Run Code Online (Sandbox Code Playgroud)
我可以覆盖SetParameters.xml文件,但我宁愿在Parameters.xml文件中设置它,但我找不到parameterEntry类型.
谢谢
我像这样制作msdeploy包:
msdeploy.exe -verb:sync -source:iisApp=c:\content\ -dest:package=c:\pkg.zip
Run Code Online (Sandbox Code Playgroud)
在C:\内容目录中有一个单一的index.html文件.
输出如下所示:
Info: Adding package (package).
Info: Adding child iisApp (c:\content\).
Info: Adding child createApp (c:\content\).
Info: Adding child contentPath (c:\content\).
Info: Adding child dirPath (c:\content\).
Info: Adding child filePath (c:\content\index.html).
Total changes: 6 (6 added, 0 deleted, 0 updated, 0 parameters changed, 0 bytes copied)
Run Code Online (Sandbox Code Playgroud)
如果我将c:\ pkg.zip的内容解压缩到目录c:\ pkg中,它看起来像这样:
archive.xml
systemInfo.xml
Content\c_C
Content\c_C\content
Content\c_C\content\index.html
Run Code Online (Sandbox Code Playgroud)
如果我像这样转储包:
msdeploy.exe -verb:dump -source:package=c:\pkg.zip -xml
Run Code Online (Sandbox Code Playgroud)
我明白了:
<output>
<MSDeploy.iisApp>
<iisApp …
Run Code Online (Sandbox Code Playgroud) 目前,我使用Visual Studio 2012在我的Web项目中配置了一个构建后事件,如下所示:
这基本上调用PowerShell脚本向每个.cs文件添加版权声明.
我想要做的是仅在将Web应用程序发布到远程服务器之前执行此PowerShell脚本.这样做我每次需要调试项目时都不会遇到延迟.你知道有什么方法可以实现吗?
根据Sayed的回答,我定制了一个特定的发布配置文件并添加了这个:
<PipelineDependsOn>
CustomBeforePublish;
$(PipelineDependsOn);
</PipelineDependsOn>
</PropertyGroup>
<Target Name="CustomBeforePublish">
<Message Text="******* CustomBeforePublish *******" Importance="high" />
<Exec Command="powershell.exe -file "$(ProjectDir)\Copyright.ps1"" />
</Target>
Run Code Online (Sandbox Code Playgroud) powershell publish msdeploy post-build-event visual-studio-2012
我正在尝试通过msbuild在新机器上构建一个Web Deploy包,但它无法正常工作.它在其他机器上构建良好,但在这里我得到以下模糊错误:
...\Microsoft.Web.Publishing.targets(2767,5): error : Filename: redirection.config
...\Microsoft.Web.Publishing.targets(2767,5): error : Error: Cannot read configuration file
...\Microsoft.Web.Publishing.targets(2767,5): error :
...\Microsoft.Web.Publishing.targets(2767,5): error : Unknown error (0x80005000)
Run Code Online (Sandbox Code Playgroud)
我不确定'redirection.config'是什么,并且.targets文件的行引用根本没有帮助.
我怎样才能解决这个问题?
msdeploy ×10
webdeploy ×3
iis ×2
asp.net-mvc ×1
c# ×1
msbuild ×1
powershell ×1
publish ×1
web-config ×1