我有一个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"
,但未成功。