title: How to emulate Visual Studios Publish in an Azure Pipeline
body: <p>I'm trying to figure out how to publish my WPF application to multiple locations. </p>
  
  <p>Reason: There is no directory/network location that all users have access to. The locally hosted agent hooked into the azure pipeline has access to locations (desired publish locations) that would allow all users to have at least a single location to access the application. </p>
  
  <p>After a while I have finally been able to publish to these locations. Now I would like to convert my publish action to emulate what Visual Studio does. </p>
  
  <p>What I mean by that is that I would like the publish folder to look like:</p>
  
  <pre><code>1. A folder called "Application Files" 
       Containing subfolders 
           MyApplicationName_1_0_0_19
           MyApplicationName_1_0_0_20
           ...
  2. `MyApplicationName.application` 
  3. `Setup.exe` &lt;- Note: I delete this file since it requires admin privileges to use. I've only included it here because Visual Studios Publish feature creates it on the first publish.
  </code></pre>
  
  <p>and not how it currently looks which is all my application files for the current publish. </p>
  
  <p>Reason: Running <code>MyApplicationName.application</code> creates a shortcut on the users desktop and when the application starts it checks for a newer version. </p>
  
  <p>The last task is where it publishes to the desired location. </p>
  
  <pre><code># ASP.NET Core (.NET Framework)
  # Build and test ASP.NET Core projects targeting the full .NET Framework.
  # Add steps that publish symbols, save build artifacts, and more:
  # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
  
  trigger:
  - master
  
  pool: Default
  
  variables:
    solution: '**/*.sln'
    buildPlatform: 'Any CPU'
    buildConfiguration: 'Release'
  
  steps:
  - task: NuGetToolInstaller@1
  
  - task: NuGetCommand@2
    inputs:
      restoreSolution: '$(solution)'
  
  - task: MSBuild@1
    inputs:
      solution: 'Tenant Tool Analytics Module/*.csproj'
      msbuildArchitecture: 'x64'
  
  
  - task: VisualStudioTestPlatformInstaller@1
    inputs:
      packageFeedSelector: 'nugetOrg'
      versionSelector: 'latestStable'
  
  
  - task: VSTest@2
    inputs:
      testSelector: 'testAssemblies'
      testAssemblyVer2: |
        **\*test*.dll
        !**\*TestAdapter.dll
        !**\obj\**
      searchFolder: '$(System.DefaultWorkingDirectory)'
      vsTestVersion: 'toolsInstaller'
  
  - task: MSBuild@1
    inputs:
        solution: 'Tenant Tool Analytics Module/*.csproj'
        msbuildArguments: '/target:Publish /p:OutDir=c:\test2\'
        msbuildArchitecture: x64
  </code></pre>
  
  <p>Note: I'm not using Azure Deployment groups for that would require Admin Privileges and getting those is a long and slow process (currently in progress and not guaranteed). If the best solution would be to go through there please comment and I'll post a new question when I have privileges to run "Registration script (PowerShell)" for a deployment group.</p>
  
  <p>I didn't create the file "MyApplicationName.application" but instead it was created by Visual Studios publish feature. I have added the code found inside it bellow. </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;asmv1:assembly xsi:schemaLocation="urn:schemas-microsoft-com:asm.v1 assembly.adaptive.xsd" manifestVersion="1.0" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns="urn:schemas-microsoft-com:asm.v2" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xrml="urn:mpeg:mpeg21:2003:01-REL-R-NS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:co.v1="urn:schemas-microsoft-com:clickonce.v1" xmlns:co.v2="urn:schemas-microsoft-com:clickonce.v2"&gt;
    &lt;assemblyIdentity name="MyApplicationName.application" version="1.0.0.20" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" xmlns="urn:schemas-microsoft-com:asm.v1" /&gt;
    &lt;description asmv2:publisher="MyApplicationName" asmv2:product="MyApplicationName" xmlns="urn:schemas-microsoft-com:asm.v1" /&gt;
    &lt;deployment install="true" co.v1:createDesktopShortcut="true"&gt;
      &lt;subscription&gt;
        &lt;update&gt;
          &lt;beforeApplicationStartup /&gt;
        &lt;/update&gt;
      &lt;/subscription&gt;
      &lt;deploymentProvider codebase="file://[Publish Path On Shared Network Drive]" /&gt;
    &lt;/deployment&gt;
    &lt;compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2"&gt;
      &lt;framework targetVersion="4.7.2" profile="Full" supportedRuntime="4.0.30319" /&gt;
    &lt;/compatibleFrameworks&gt;
    &lt;dependency&gt;
      &lt;dependentAssembly dependencyType="install" codebase="Application Files\MyApplicationName_1_0_0_20\MyApplicationName.exe.manifest" size="7240"&gt;
        &lt;assemblyIdentity name="MyApplicationName.exe" version="1.0.0.20" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" /&gt;
        &lt;hash&gt;
          &lt;dsig:Transforms&gt;
            &lt;dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" /&gt;
          &lt;/dsig:Transforms&gt;
          &lt;dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" /&gt;
          &lt;dsig:DigestValue&gt;6P...gi+j6...nY=&lt;/dsig:DigestValue&gt;
        &lt;/hash&gt;
      &lt;/dependentAssembly&gt;
    &lt;/dependency&gt;
  &lt;/asmv1:assembly&gt;
  </code></pre>