gpt4 book ai didi

msbuild - 使用MsBuild通过命令行进行发布单击时出现问题

转载 作者:行者123 更新时间:2023-12-03 15:14:44 25 4
gpt4 key购买 nike

我的解决方案中的csproj中有Windows应用程序,我想使用命令行(bat,cmd)生成发布。

我的脚本是(我放入\r\n以便于阅读):

 SET MSBUILD="%SystemRoot%\Microsoft.NET\Framework\v3.5\MSBuild.exe"
SET CARWIN="..\..\Security.CarWin.csproj"

rem msbuild para publish

%MSBUILD% /target:rebuild;publish %CARWIN%
/p:ApplicationVersion="1.0.0.0"
/p:Configuration=release
/p:PublishUrl="C:\ClickOnce\CarWin.WebInstall\Publicacion\"
/p:InstallUrl="http://desserver/carwinclickonce/Publicacion/"
/p:PublishDir="C:\ClickOnce\CarWin.WebInstall\Publicacion\"

注意:我也会尝试使用 /target:publish
但是在路径PublishDir或PublishUrl(C:\ ClickOnce \ CarWin.WebInstall \ Publicacion)中不会生成任何文件。

我已经在该网站和google上看到了很多帖子,但没有找到任何解决方案。

最佳答案

看看this Stack Overflow question。从命令行运行ClickOnce时,基本上会忽略PublishUrl属性。但是您可以通过附加的MSBuild任务轻松添加行为。

我创建了一个附加的MSBuild-File,例如build.csproj。它包含一个publish-task。此任务首先调用目标项目的常规MS-Build。之后,它将结果复制到publish-directory。现在,我从命令行调用“build.csproj”而不是常规的项目文件:

    <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Publish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- project name-->
<ProjectName>MyExampleProject</ProjectName>
<!--properties for the project-build-->
<DefaultBuildProperties>Configuration=Release</DefaultBuildProperties>
<!-- location of the click-once stuff, relative to the project -->
<ProjectPublishLocation>.\bin\Release\app.publish</ProjectPublishLocation>
<!-- Location you want to copy the click-once-deployment. Here an windows-share-->
<ProjectClickOnceFolder>\\TargetServer\deployments</ProjectClickOnceFolder>
</PropertyGroup>
<Target Name="Publish" DependsOnTargets="Clean">
<Message Text="Publish-Build started for build no $(ApplicationRevision)" />
<!-- run the original build of the project -->
<MSBuild Projects="./$(ProjectName).csproj"
Properties="$(DefaultBuildProperties)"
Targets="Publish"/>
<!-- define the files required for click-once-->
<ItemGroup>
<SetupFiles Include="$(ProjectPublishLocation)\*.*"/>
<UpdateFiles Include="$(ProjectPublishLocation)\Application Files\**\*.*"/>
</ItemGroup>
<!-- and copy them -->
<Copy
SourceFiles="@(SetupFiles)"
DestinationFolder="$(ProjectClickOnceFolder)\"/>
<Copy
SourceFiles="@(UpdateFiles)"
DestinationFolder="$(ProjectClickOnceFolder)\Application Files\%(RecursiveDir)"/>
</Target>
<Target Name="Clean">
<Message Text="Clean project" />
<MSBuild Projects="./$(ProjectName).csproj"
Properties="$(DefaultBuildProperties)"
Targets="Clean"/>
</Target>
</Project>

关于msbuild - 使用MsBuild通过命令行进行发布单击时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2130985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com