使用 MsBuild 使用命令行进行发布时出现问题单击一次 [英] Problems using MsBuild using command line for Publish Click Once

查看:21
本文介绍了使用 MsBuild 使用命令行进行发布时出现问题单击一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have Windows application in csproj in my solution, and I want generate Publish using command line (bat, cmd).

我的脚本是(我放了 以便更好地阅读):

My script is (I put for better reading):

 SET MSBUILD="%SystemRoot%Microsoft.NETFrameworkv3.5MSBuild.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:ClickOnceCarWin.WebInstallPublicacion" 
/p:InstallUrl="http://desserver/carwinclickonce/Publicacion/" 
/p:PublishDir="C:ClickOnceCarWin.WebInstallPublicacion" 

注意:我也会尝试使用 /target:publish

note: I'll try too using /target:publish

但在路径 PublishDir 或 PublishUrl (C:ClickOnceCarWin.WebInstallPublicacion) 中不会生成任何文件.

But in path PublishDir or PublishUrl (C:ClickOnceCarWin.WebInstallPublicacion) not generates any files.

我在这个网站和谷歌上看到了很多帖子,但我没有找到任何解决方案.

I have seen many posts in this site and google but I not found any solution.

推荐答案

看看这个 Stack Overflow 问题.从命令行运行 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-File,例如 build.csproj.这包含一个发布任务.此任务首先调用目标项目的常规 MS-Build.然后它将结果复制到发布目录.现在我从命令行调用build.csproj"而不是 reguar 项目文件:

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>.inReleaseapp.publish</ProjectPublishLocation> 
        <!-- Location you want to copy the click-once-deployment. Here an windows-share-->
        <ProjectClickOnceFolder>\TargetServerdeployments</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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆