MSBuild 不尊重我的 ClickOnce 应用程序的 PublishUrl 属性

标签 msbuild clickonce

我正在尝试制作一个批处理文件以一键发布我们拥有的少数 ClickOnce 应用程序。我为此使用了 msbuild,作为示例,下面的命令行显示了我是如何做的:

msbuild
    MyApp.sln
    /t:Publish
    /p:Configuration=Release
    /p:PublishUrl="C:\Apps\"
    /v:normal > Log.txt

(包装方便阅读)

当我运行上述命令时,它会在发布目录中构建并发布应用程序,即 bin\release!知道为什么 msbuild 在我上面的例子中不尊重 PublishUrl 属性吗?

PS:我还尝试了不同的组合,包括删除“配置”,使用“重建”和“仅发布”作为目标,并删除引号但没有成功。

最佳答案

某些功能由 Visual-Studio 完成,而不是由 MSBuild 脚本完成。因此,当从命令行执行时,单击一次部署的行为会有所不同。

  • ApplicationRevision 不会随着每次构建而增加。这仅在从 Visual Studio 执行时有效
  • 在某些情况下,不使用 PublishUrl。 Quote from MSDN :

    For example, you could set the PublishURL to an FTP path and set the InstallURL to a Web URL. In this case, the PublishURL is only used in the IDE to transfer the files, but not used in the command-line builds. Finally, you can use UpdateUrl if you want to publish a ClickOnce application that updates itself from a separate location from which it is installed.


  • 我创建了一个特殊的 MSBuild 文件来做这些事情。它运行发布目标并将文件复制到正确的位置。

    alhambraeidos 要求的构建文件示例。它基本上运行常规的 VisualStudio-build,然后将单击一次数据复制到真正的发布文件夹。请注意,删除了一些特定于项目的内容,因此它可能已损坏。此外,它不会增加内部版本号。这是由我们的 Continues-Build-Server 完成的:
    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Publish" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <PropertyGroup>
            <!-- the folder of the project to build -->
            <ProjLocation>..\YourProjectFolder</ProjLocation>
            <ProjLocationReleaseDir>$(ProjLocation)\bin\Release</ProjLocationReleaseDir>
            <ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
            <!-- This is the web-folder, which provides the artefacts for click-once. After this
             build the project is actually deployed on the server -->
            <DeploymentFolder>D:\server\releases\</DeploymentFolder>
        </PropertyGroup>
    
    
        <Target Name="Publish" DependsOnTargets="Clean">
            <Message Text="Publish-Build started for build no $(ApplicationRevision)" />
            <MSBuild Projects="$(ProjLocation)/YourProject.csproj" Properties="Configuration=Release" Targets="Publish"/>   
    
    
            <ItemGroup>
                <SchoolPlannerSetupFiles Include="$(ProjPublishLocation)\*.*"/>
                <SchoolPlannerUpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
            </ItemGroup>
            <Copy
                SourceFiles="@(SchoolPlannerSetupFiles)"
                DestinationFolder="$(DeploymentFolder)\"
            />
            <Copy
                SourceFiles="@(SchoolPlannerUpdateFiles)"
                DestinationFolder="$(DeploymentFolder)\Application Files\%(RecursiveDir)"
            />      
            <CallTarget Targets="RestoreLog"/>
        </Target>
        <Target Name="Clean">   
            <Message Text="Clean project:" />
            <MSBuild Projects="$(ProjLocation)/YourProject.csproj" Properties="Configuration=Release" Targets="Clean"/>
        </Target>       
    </Project>
    

    关于MSBuild 不尊重我的 ClickOnce 应用程序的 PublishUrl 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1919625/

    相关文章:

    c# - dotnet 和 msbuild 中的包之间的区别

    c# - 如何使用 csproj 多目标 .NET Core 类库?

    c# - 以编程方式更新 ClickOnce 应用程序的部署 list 会导致缺少 <compatibleFrameworks> 元素,这在 4.0 中是必需的

    visual-studio - ReferencePath 与 ReferenceCopyLocalPaths

    c# - Microsoft.TeamTest.targets 中的 MSBuild NullReferenceException

    .net - NuGet 自动包还原不适用于 MSBuild

    .net - 无法在 Visual Studio 2012 的 .NET 4.0 应用程序上使用 ClickOnce 发布

    .net - 仅将部分先决条件与 ClickOnce 捆绑在一起

    .NET ClickOnce 签名导致 "Unknown Publisher"

    certificate - Clickonce 应用程序已签名,但下载时发布者仍然未知