ApplicationFiles folder missing when ClickOnce publish with command line

前端 未结 1 801
天命终不由人
天命终不由人 2021-01-17 02:19

ClickOnce publish with IDE works normal.

When trying to publish via MSBuild command line

%MSBUILD% /target:publish /p:Configuration=Release;PublishDi         


        
相关标签:
1条回答
  • 2021-01-17 02:34

    How do I publish via command line same ClickOnce settings which IDE uses

    Some features are done by Visual-Studio and not by the MSBuild command line. So the click-once-deployment behaves differently when it's executed from the command-line.

    If you want to publish via command line same ClickOnce settings which IDE uses, you can use a custom target to achieve it. Edit your project(csproj) file (right click project node -> unload project -> edit xxx.csproj) and add the following code in it:

      <PropertyGroup>
        <ProjLocation>D:\Test\Projects\ClickOncePublish\ClickOncePublish</ProjLocation>
        <ProjLocationReleaseDir>$(ProjLocation)\bin\Debug</ProjLocationReleaseDir>
        <ProjPublishLocation>$(ProjLocationReleaseDir)\app.publish</ProjPublishLocation>
        <DeploymentFolder>D:\Test\Publish\</DeploymentFolder>
      </PropertyGroup>
    
    
      <Target Name="Test" DependsOnTargets="Clean">
    
        <MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
            Properties="$(DefaultBuildProperties)"
            Targets="Publish"/>
    
        <ItemGroup>
          <SetupFiles Include="$(ProjPublishLocation)\*.*"/>
          <UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
        </ItemGroup>
    
    
        <Copy SourceFiles="@(SetupFiles)" DestinationFolder="$(DeploymentFolder)\" />
        <Copy SourceFiles="@(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Application Files\%(RecursiveDir)"/>
      </Target>
    
      <Target Name="Clean">
        <Message Text="Clean project" />
        <MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
        Properties="$(DefaultBuildProperties)"
        Targets="Clean"/>
      </Target>
    

    Then you can build the project with the MSBuild command line:

    msbuild /target:test
    

    After execute the build command, all the expected files are publish via command line same ClickOnce settings which IDE uses.

    Note: You should change the value of ProjLocation to the path of your project.

    0 讨论(0)
提交回复
热议问题