7

我有一个从命令行发布的 Web 项目,使用发布配置文件执行一些额外的任务(不包括一些文件和文件夹,咕噜声,依次发布另一个项目)。

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

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

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 中工作正常,使用右键单击发布。

在登录机器 AI 中获取以下摘录:

**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"按照此处所述添加,但这不起作用。

4

1 回答 1

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 进行了一些更改,因此很可能导致了这个问题。

于 2014-04-08T12:50:53.197 回答