通过命令行使用MsBuild进行发布单击时出现问题 [英] Problems using MsBuild using command line for Publish Click Once
问题描述
我的解决方案中的csproj中有Windows应用程序,我想使用命令行(bat,cmd)生成发布.
I have Windows application in csproj in my solution, and I want generate Publish using command line (bat, cmd).
我的脚本是(为了更好阅读,我放了\r\n
):
My script is (I put \r\n
for better reading):
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
note: I'll try too using /target:publish
但是在路径PublishDir或PublishUrl(C:\ ClickOnce \ CarWin.WebInstall \ Publicacion)中不会生成任何文件.
But in path PublishDir or PublishUrl (C:\ClickOnce\CarWin.WebInstall\Publicacion) not generates any files.
我在该网站和google上看到了很多帖子,但找不到任何解决方案.
I have seen many posts in this site and google but I not found any solution.
推荐答案
看看此堆栈溢出问题.从命令行运行ClickOnce时,基本上忽略PublishUrl
属性.但是您可以通过附加的MSBuild任务轻松添加行为.
Take a look at this Stack Overflow question. Basically the PublishUrl
property is ignored when running ClickOnce from the command line. But you can easily add the behaviour with an additional MSBuild-task.
我创建了一个附加的MSBuild文件,例如build.csproj
.它包含一个publish-task
.此任务首先调用目标项目的常规MS-Build.之后,它将结果复制到publish-directory.现在,我从命令行调用"build.csproj"而不是常规的项目文件:
I've created an additional MSBuild-File, for example a build.csproj
. This contains a publish-task
. This task first invokes the regular MS-Build of the target-project. Afterwards it copies the result to the publish-directory. Now I invoke the 'build.csproj' instead of the reguar project-file from the command-line:
<?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进行发布单击时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!