使用命令行进行MSBuild发布Web项目时,会生成Package而不是FileSystem

7

我有一个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

我能想到两台机器之间的唯一区别是,我在机器B(有问题的机器)上安装了“Windows Azure SDK for .NET(VS2013)-2.3”的更新。您有什么想法,为什么会有这种情况发生吗?
我尝试按照这里提到的方法添加/p:PublishProfileRootFolder="Properties\PublishProfiles",但未成功。
1个回答

14

在命令中添加:

/p:VisualStudioVersion=12.0

即可解决问题。

机器B上安装了Visual Studio 2008,而机器A没有安装。将版本设置为12.0,甚至11.0都可以解决问题。将其设置为10.0将忽略发布配置文件,只进行包的安装。

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

这个问题出现在更新到Azure SDK 2.3之后,该更新对Web Publish进行了一些更改,因此可能导致了这个问题。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接