简体   繁体   English

MSBUILD脚本构建解决方案,但不部署发布配置文件

[英]MSBUILD script building solution, but not deploying publishing profile

I have created a publishing profile for my web page, and I can successfully publish using the web deploy interface in Visual Studio (right click project, deploy etc). 我已经为我的网页创建了一个发布配置文件,并且可以使用Visual Studio中的Web部署界面(右键单击项目,部署等)成功发布。 It builds the project on my local PC, and copies the files across to destination IIS server. 它在我的本地PC上构建项目,然后将文件复制到目标IIS服务器。

But now I am trying to create a MSBuild command, which should do the same, but it is only building the solution, not copying it across to the server. 但是现在我试图创建一个MSBuild命令,该命令应该执行相同的操作,但是它只是构建解决方案,而不是将其复制到服务器上。

My MSbuild command looks like this, and I run it from the solution source directory 我的MSbuild命令如下所示,我从解决方案源目录运行它

msbuild "test.co.za.sln" p:DeployOnBuild=true /p:PublishProfile="test.co.za"  /p:UserName="domain\test"  /p:Password="test"

Is there anything wrong with my build command? 我的构建命令有什么问题吗? As you can see in the screenshot, it is building successfully, but no files are being copied across. 正如您在屏幕截图中看到的那样,它正在成功构建,但是没有文件被复制。 Which makes me wonder if the publishing profile is executed at all. 这让我想知道发布配置文件是否完全执行。 I have tried various combinations of publishprofile paths, full paths, with extensions, without, nothing seems to copy my files accross. 我尝试了publishprofile路径,完整路径以及扩展名的各种组合,但没有,似乎没有什么可以复制我的文件。

在此处输入图片说明

My publishing profile looks like this App_Data\\Publishprofile\\test.co.za.pubxml 我的发布配置文件如下所示: 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>

EDIT: This is an existing classic ASP website which I added to a solution, it doesn't contain a ".csproj" file, just a "website.publishproj", which doesn't seem to execute 编辑:这是一个现有的经典ASP网站,我将其添加到解决方案中,它不包含“ .csproj”文件,仅包含一个“ website.publishproj”文件,该文件似乎没有执行

It doesn't look like you are passing in the VisualStudioVersion property. 看起来您好像没有传入VisualStudioVersion属性。 You should include that. 您应该包括在内。 The value will either be 11.0 , 12.0 , or 14.0 based on the version of Visual Studio you are using. 该值要么是11.012.0 ,或14.0基于Visual Studio版本所使用。 You should likely pass in a value for Configuration as well but it's not required. 您可能还应该为Configuration传递一个值,但这不是必需的。 I've blogged about why this is important at http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx . 我在http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx上写了关于为什么这很重要的博客。

You can find the docs for asp.net command line publishing at http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment 您可以在http://www.asp.net/mvc/tutorials/deployment/visual-studio-web-deployment/command-line-deployment中找到用于asp.net命令行发布的文档

Looks like my "website.publishingproj" is never being built when I run the msbuild command. 当我运行msbuild命令时,似乎从未构建过“ website.publishingproj”。 Not sure why, @Sayed do you perhaps know? 不知道为什么,@ Sayed您可能知道吗?

I had to create a targets file next to my solution called "after.solutionName.sln.targets" and copy the code from this answer : https://stackoverflow.com/a/15138373/1184603 我必须在解决方案旁边创建一个目标文件“ 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>

It now publishes correctly from my msbuild script. 现在,它可以从我的msbuild脚本正确发布。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM