因此,我为我的网络应用程序创建了一个发布配置文件。我在VS 2017 Enterprise中用GUI做了这件事。然后,我找到了一个如何更改pubxml以使其压缩所有输出文件的示例。最终我得到了这样的结果:
<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不知道它吗?这看起来就像它的表现。
发布于 2018-11-28 14:30:32
在Jenkins中使用msbuild时也遇到了同样的问题。要使用msbuild执行目标GatherAllFilesToPublish,我必须在msbuild命令行中添加目标/t:GatherAllFilesToPublish。
你应该有这样的东西:
/p:DeployOnBuild=true /p:PublishProfile=fullPathToMyPubXML.pubxml /t:GatherAllFilesToPublish
https://stackoverflow.com/questions/53423119
复制相似问题