首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MSBuild忽略GatherAllFilesToPublish?

MSBuild忽略GatherAllFilesToPublish?
EN

Stack Overflow用户
提问于 2018-11-22 02:38:11
回答 1查看 493关注 0票数 1

因此,我为我的网络应用程序创建了一个发布配置文件。我在VS 2017 Enterprise中用GUI做了这件事。然后,我找到了一个如何更改pubxml以使其压缩所有输出文件的示例。最终我得到了这样的结果:

代码语言:javascript
复制
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <PublishProvider>FileSystem</PublishProvider>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <SiteUrlToLaunchAfterPublish />
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <PrecompileBeforePublish>True</PrecompileBeforePublish>
        <EnableUpdateable>True</EnableUpdateable>
        <DebugSymbols>False</DebugSymbols>
        <WDPMergeOption>DonotMerge</WDPMergeOption>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <publishUrl>bin\Release\Publish</publishUrl>
        <DeleteExistingFiles>True</DeleteExistingFiles>
        <Configuration>Release</Configuration>
    </PropertyGroup>
    <Target Name="ZipPublishOutput" AfterTargets="GatherAllFilesToPublish">
        <Exec Command='powershell -nologo -noprofile -command "compress-archive -force -path $(WPPAllFilesInSingleFolder)\* -destinationpath $(publishUrl).zip"' />
    </Target>
</Project>

如果我通过Visual进行发布,这是非常好的。然而,我一直在尽我所能使它在MSBuild中工作,却没有任何运气。

下面是我认为应该起作用的一个例子:

"C:\Program (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe“WebApp.csproj /nologo /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=ReleasePublish

作为参考,下面是MSBuild的版本:

Microsoft (R)为.NET框架构建引擎版本.NET

我知道MSBuild正在查找概要文件pubxml,因为我可以对设置(如publishUrl )进行更改,这些更改将在下次运行MSBuild时应用。似乎不起作用的是ZipPublishOutput目标。即使以诊断性详细的方式运行MSBuild也表明,GatherAllFilesToPublish从未运行过,这意味着我的目标不会运行。

我发现了许多不同的建议,但似乎没有任何帮助。我找到的许多解决方案似乎都是用MSBuild找不到pubxml,但这里不是这样的。

那么,GatherAllFilesToPublish是特定于Visual的东西,因此MSBuild不知道它吗?这看起来就像它的表现。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-28 14:30:32

在Jenkins中使用msbuild时也遇到了同样的问题。要使用msbuild执行目标GatherAllFilesToPublish,我必须在msbuild命令行中添加目标/t:GatherAllFilesToPublish。

你应该有这样的东西:

/p:DeployOnBuild=true /p:PublishProfile=fullPathToMyPubXML.pubxml /t:GatherAllFilesToPublish

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53423119

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档