How to publish a ClickOnce application using an assembly definition?

I am currently publishing the ClickOnce application manually by right-clicking .csproj. Is there a way that I can do the same from a solution directly so that I can use it with a build definition for continuous integration?

+5
source share
1 answer

You cannot publish the ClickOnce application from the solution directly, but you can create and publish the ClickOnce application using the XAML assembly and the vNext assembly and use the MSBuild argument "/ target: publish" to force MSBuild to create the ClickOnce publish folder. Here are two blogs with detailed instructions on creating and publishing a ClickOnce application:

Create and publish the ClickOnce application using Team Build / VSO, please refer to the blog: http://blogs.msdn.com/b/tfssetup/archive/2015/09/15/build-and-publish-a-clickonce- app-using-team-build-vso.aspx

Creating ClickOnce applications using the vNext assembly, please refer to the blog: http://blogs.msdn.com/b/tfssetup/archive/2015/10/15/building-clickonce-apps-using-build-vnext.aspx

Assuming you are using the XAML assembly, so I would like to highlight the points in the blog using the XAML assembly. To create and publish a ClickOnce application using Team Build, you need to edit the XAML assembly definition with the following steps:

  • Set the publication path in the project properties to match the destination. Then test your project on TFS.

  • Create a copy of the TFVCTemplate.12.xaml template to complete the setup. In order for the build process to get some environment data, you need to:

    • Create two environment variables - DropLocation and WorkingDirectory.

    • Add two events of the GetEnvironmentVariable type to the tool window. Add them to any place in the stream.

    • Use the first to set the DropLocation variable with the data "Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.DropLocation".

    • Use the second variable to set the WorkingDirectory variable with the data "Microsoft.TeamFoundation.Build.Activities.Extensions.WellKnownEnvironmentVariables.BuildDirectory".

    • Create a new argument of type DestinationLocation and set the value to In with type String. This will be used to store the location (file location) where your final data will be sent.

The reason we are editing the XAML assembly definition is because ClickOnce publishing is done by MsBuild. MSBuild publish does not copy files to the destination, it creates a folder in the trash and puts the files there.

  1. As by default, TFS copies the bin folder to the output location. But we need the app.publish folder. To find a way to publish published files from the publish folder. You need:

    • Locate the "Copy binary files to delete" action in the template.

    • In properties on top of an existing source location (which would be a bin folder, such as WorkingDirectory + "\ src \ Desktop \ TeamAdmin \ ClickOnceTest \ ClickOnceTest) to something like this: WorkDirectory +" \ src \ Desktop \ TeamAdmin \ ClickOnceTest \ ClickOnceTest \ Bin \ Debug \ app.publish ".

  2. Add the CreateDirectory event to re-create the directory. We can use the destination variable that we created earlier. And copy the files from the drag and drop location to the desired location.

  3. Now we can create a new assembly definition and enter the value for DestinationLocation and MSBuildArguments "/ target: publish" and queue the assembly.

+3
source

Source: https://habr.com/ru/post/1236855/


All Articles