![](/img/trans.png)
[英]Building specific project in a solution using MSBuild in Azure DevOps
[英]MSBUILD script building solution, but not deploying publishing profile
我已经为我的网页创建了一个发布配置文件,并且可以使用Visual Studio中的Web部署界面(右键单击项目,部署等)成功发布。 它在我的本地PC上构建项目,然后将文件复制到目标IIS服务器。
但是现在我试图创建一个MSBuild命令,该命令应该执行相同的操作,但是它只是构建解决方案,而不是将其复制到服务器上。
我的MSbuild命令如下所示,我从解决方案源目录运行它
msbuild "test.co.za.sln" p:DeployOnBuild=true /p:PublishProfile="test.co.za" /p:UserName="domain\test" /p:Password="test"
我的构建命令有什么问题吗? 正如您在屏幕截图中看到的那样,它正在成功构建,但是没有文件被复制。 这让我想知道发布配置文件是否完全执行。 我尝试了publishprofile路径,完整路径以及扩展名的各种组合,但没有,似乎没有什么可以复制我的文件。
我的发布配置文件如下所示: App_Data \\ Publishprofile \\ test.co.za.pubxml
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<SiteUrlToLaunchAfterPublish>http://test.co.za</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<MSDeployServiceURL>test.co.za</MSDeployServiceURL>
<DeployIisAppPath>test.co.za</DeployIisAppPath>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<UserName>domain\test</UserName>
<_SavePWD>True</_SavePWD>
</PropertyGroup>
</Project>
编辑:这是一个现有的经典ASP网站,我将其添加到解决方案中,它不包含“ .csproj”文件,仅包含一个“ website.publishproj”文件,该文件似乎没有执行
看起来您好像没有传入VisualStudioVersion
属性。 您应该包括在内。 该值要么是11.0
, 12.0
,或14.0
基于Visual Studio版本所使用。 您可能还应该为Configuration
传递一个值,但这不是必需的。 我在http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx上写了关于为什么这很重要的博客。
您可以在http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment中找到用于asp.net命令行发布的文档。
当我运行msbuild命令时,似乎从未构建过“ website.publishingproj”。 不知道为什么,@ Sayed您可能知道吗?
我必须在解决方案旁边创建一个目标文件“ after.solutionName.sln.targets”,然后从以下答案中复制代码: https ://stackoverflow.com/a/15138373/1184603
<!--?xml version="1.0" encoding="utf-8"?-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Deploy Website" AfterTargets="Build">
<Message Text="Starting Website deployment" Importance="high">
</Message>
<MSBuild Projects="$(MSBuildProjectDirectory)\MyWebs\website.publishproj"
BuildInParallel="true" />
</Target>
</Project>
现在,它可以从我的msbuild脚本正确发布。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.