MSBuild从命令行发布Web项目执行Package而不是FileSystem

时间:2014-04-08 12:18:30

标签: msbuild visual-studio-2013 publish-profiles

我有一个Web项目,我从命令行发布,使用发布配置文件执行一些额外的任务(排除一些文件和文件夹,grunt,依次发布另一个项目)。

一台两台机器(A和B),右键单击>工作正常在Visual Studio中发布...,然后选择正确的发布配置文件。

从历史上看,在两台机器上,它也可以使用以下命令行:

msbuild MyProject.csproj /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=myProfile  /v:n

但是现在,机器B没有正确发布。

发布配置文件在顶部配置了<WebPublishMethod>FileSystem</WebPublishMethod,但是从日志中,它正在尝试Package发布类型,而无明显原因。

以下是完整的发布资料:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <publishUrl>..\Production</publishUrl>
        <DeleteExistingFiles>False</DeleteExistingFiles>
        <ExcludeFoldersFromDeployment>Content;Scripts;Pages</ExcludeFoldersFromDeployment>
        <ExcludeFilesFromDeployment>index-dev.html;index.html;debug.html;JSLintNet.json;Gruntfile.js;package.json;packages.config;publishall.bat;publishapi.bat</ExcludeFilesFromDeployment>
        <BuildDependsOn>
            $(BuildDependsOn);
            RunGrunt;
            PublishApi;
        </BuildDependsOn>
    </PropertyGroup>
    <Target Name="RunGrunt">
        <Message Text="Running grunt production..." />
        <Exec Command="grunt production" />
    </Target>
    <Target Name="PublishApi">
        <Message Text="Publishing API..." />
        <Exec Command="publishapi" />
    </Target>
</Project>

正如您所期望的那样,因为它只是在执行Package,所以publishUrl目录中不会出现任何文件。同样,使用右键单击发布,发布配置文件在VS2013中运行良好。

在登录机器A上我得到这个摘录:

**ValidatePublishProfileSettings**:
  Validating PublishProfile(myProfile) settings.

但是在机器B中它并没有出现。

稍后在登录机器A中它包含:

**WebFileSystemPublish**:
  Creating directory "..\Production".
  Copying obj\Release\Package\PackageTmp\cache.manifest to C:\SVN\Trunk\src\Web Sites\MyProject\..\Production\cache.manifest.
  Copying obj\Release\Package\PackageTmp\Global.asax to C:\SVN\Trunk\src\Web Sites\MyProject\..\Production\Global.asax.
  Copying obj\Release\Package\PackageTmp\Web.config to C:\SVN\Trunk\src\Web Sites\MyProject\..\Production\Web.config.
  Copying obj\Release\Package\PackageTmp\bin\MyProject.dll to C:\SVN\Trunk\src\Web Sites\MyProject\..\Production\Blithe.Web.Collect.dll.

但稍后在登录机器B上,代替上述内容,它包含:

**Package**:   
  Invoking Web Deploy to generate the package with the following settings:   
  $(LocalIisVersion) is 7  
  $(DestinationIisVersion) is 7   
  $(UseIis) is True   
  $(IisUrl) is <<<some url>>>  
  $(IncludeIisSettings) is False  
  $(_DeploymentUseIis) is False   
  $(DestinationUseIis) is False

我能想到的两台机器之间的唯一区别是,我在Windows Azure SDK for .NET(VS2013) - 2.3&#39;上的机器B(问题机器)上安装了更新。任何想法如何以及为什么会破坏它?

我尝试按照here添加/p:PublishProfileRootFolder="Properties\PublishProfiles",但这不起作用。

1 个答案:

答案 0 :(得分:14)

添加:

/p:VisualStudioVersion=12.0

命令工作。

机器B上也安装了Visual Studio 2008,而机器A则没有。将版本设置为12.0甚至11.0可以正常工作。将其设置为10.0会忽略发布配置文件,只是执行包安装。

令人惊讶的是,它似乎默认为10.0。

直到Azure SDK 2.3的更新才出现此问题,DID对Web Publish进行了一些更改,因此很可能导致此问题。

相关问题