我的解决方案中有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)中不会生成任何文件。
我在这个网站和谷歌看过很多帖子,但我找不到任何解决方案。
答案 0 :(得分:22)
从命令行运行时使用PublishDir而不是PublishUrl。
msbuild /target:publish /p:Configuration=Release;PublishDir=c:\playground\
您还可以更改版本,例如ApplicationRevision = 666; MinimumRequiredVersion = 1.1
答案 1 :(得分:12)
看看this Stack Overflow question。基本上,从命令行运行ClickOnce时会忽略PublishUrl
属性。但您可以使用其他MSBuild任务轻松添加行为。
我已经创建了一个额外的MSBuild文件,例如build.csproj
。这包含publish-task
。此任务首先调用目标项目的常规MS-Build。然后,它将结果复制到publish-directory。现在我从命令行调用'build.csproj'而不是reguar项目文件:
<?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>
答案 2 :(得分:2)
我不知道这是不是问题,但我注意到你传递/ target参数两次?
您可以使用以分号分隔的示例:
/target:rebuild;publish
MSDN Documentation on command line parameters and MSBuild
如果这也不起作用,您可以尝试通过传递
来调试它/verbosity:diag