简体   繁体   English

MSBuild忽略GatherAllFilesToPublish吗?

[英]MSBuild ignores GatherAllFilesToPublish?

So, I created a publish profile for my web app. 因此,我为我的Web应用程序创建了一个发布配置文件。 I did this with the GUI in VS 2017 Enterprise. 我使用VS 2017 Enterprise中的GUI进行了此操作。 I then found an example of how to change the pubxml to make it zip all the output files. 然后,我找到了一个示例,说明如何更改pubxml以使其压缩所有输出文件。 Eventually I ended up with this: 最终我最终得到了这个:

<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>

This works perfectly fine if I do a publish through Visual Studio. 如果我通过Visual Studio进行发布,则效果很好。 However, I've been trying everything I can think of to get this to work in MSBuild, with no luck. 但是,我一直在尝试我能想到的一切,以使其在MSBuild中正常工作,但是没有运气。

Here is an example of what I think should work: 这是我认为应该起作用的示例:

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

And for reference, here is the version of MSBuild: 供参考,以下是MSBuild的版本:

Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Framework 适用于.NET Framework的Microsoft(R)Build Engine版本15.9.20 + g88f5fadfbe

I know MSBuild is finding the profile pubxml because I can make a change to the settings, such as publishUrl, and those changes are applied the next time I run MSBuild. 我知道MSBuild正在查找配置文件pubxml,因为我可以更改设置,例如publishUrl,并且这些更改将在下次运行MSBuild时应用。 What doesn't seem to work is the ZipPublishOutput target. ZipPublishOutput目标似乎无效。 And even running MSBuild with diagnostic verbosity shows that GatherAllFilesToPublish never runs, which would mean my target wouldn't run. 甚至以诊断性详细程度运行MSBuild都表明GatherAllFilesToPublish从未运行,这意味着我的目标无法运行。

I've found many different suggestions and nothing seems to help. 我发现了许多不同的建议,似乎无济于事。 A lot of the solutions I found seemed to be with MSBuild not finding the pubxml, but that's not the case here. 我发现许多解决方案似乎是与MSBuild一起找到的pubxml,但事实并非如此。

So, is GatherAllFilesToPublish something that is Visual Studio specific, and therefore MSBuild doesn't know about it? 那么,GatherAllFilesToPublish是Visual Studio特定的东西,因此MSBuild不知道吗? That seems like how it's acting. 看起来好像是这样。

Just got the same problem using msbuild with Jenkins. 使用msbuild和Jenkins遇到了同样的问题。 To execute the target GatherAllFilesToPublish with msbuild I had to add the target /t:GatherAllFilesToPublish in the msbuild command line. 要使用msbuild执行目标GatherAllFilesToPublish ,我必须在msbuild命令行中添加目标/ t:GatherAllFilesToPublish

You should have something like this : 您应该有这样的东西:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM