Reputation: 2436
I'm trying to figure out how to publish my WPF application to multiple locations.
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.
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.
What I mean by that is that I would like the publish folder to look like:
1. A folder called "Application Files"
Containing subfolders
MyApplicationName_1_0_0_19
MyApplicationName_1_0_0_20
...
2. `MyApplicationName.application`
3. `Setup.exe` <- 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.
and not how it currently looks which is all my application files for the current publish.
Reason: Running MyApplicationName.application
creates a shortcut on the users desktop and when the application starts it checks for a newer version.
The last task is where it publishes to the desired location.
# 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://learn.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
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.
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.
<?xml version="1.0" encoding="utf-8"?>
<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">
<assemblyIdentity name="MyApplicationName.application" version="1.0.0.20" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" xmlns="urn:schemas-microsoft-com:asm.v1" />
<description asmv2:publisher="MyApplicationName" asmv2:product="MyApplicationName" xmlns="urn:schemas-microsoft-com:asm.v1" />
<deployment install="true" co.v1:createDesktopShortcut="true">
<subscription>
<update>
<beforeApplicationStartup />
</update>
</subscription>
<deploymentProvider codebase="file://[Publish Path On Shared Network Drive]" />
</deployment>
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2">
<framework targetVersion="4.7.2" profile="Full" supportedRuntime="4.0.30319" />
</compatibleFrameworks>
<dependency>
<dependentAssembly dependencyType="install" codebase="Application Files\MyApplicationName_1_0_0_20\MyApplicationName.exe.manifest" size="7240">
<assemblyIdentity name="MyApplicationName.exe" version="1.0.0.20" publicKeyToken="0000000000000000" language="neutral" processorArchitecture="amd64" type="win32" />
<hash>
<dsig:Transforms>
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
</dsig:Transforms>
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
<dsig:DigestValue>6P...gi+j6...nY=</dsig:DigestValue>
</hash>
</dependentAssembly>
</dependency>
</asmv1:assembly>
Upvotes: 5
Views: 6755
Reputation: 2436
It seems that I needed to add the property OutputPath and OutDir to my msbuildArguments for my deployment to work correctly.
- task: MSBuild@1
inputs:
solution: 'Tenant Tool Analytics Module/*.csproj'
msbuildArguments: '/target:Publish
/p:ApplicationVersion=$(AssemblyVersion)
/p:UpdateEnabled=true /p:UpdateMode=Foreground
/p:ProductName=TenantAnalyticsTool
/p:InstallUrl=c:\sandbox\deploytesting\siteA
/p:PublishUrl=c:\sandbox\deploytesting\siteA
/p:UpdateUrl=c:\sandbox\deploytesting\siteA
/p:OutputPath=c:\sandbox\deploytesting\siteA
/p:OutDir=c:\sandbox\deploytesting\siteA '
msbuildArchitecture: x64
Upvotes: 2
Reputation: 19361
Since WPF framework is part of .NET, you can select .NET DeskTop
template in build pipeline and use Publish Artifact
task to deploy a .Net desktop app build artifact to shared network drive folder.
Set Artifact publish location
to A file share
then you need enter your network drive folder path.
If you want to deploy to multiple network drives ,you can add multiple Publish Artifact
tasks. You can refer to this case with similar issue.
If you want to deploy to a large number of locations and don't want to add multiple tasks, a better way is to use deployment group.
Upvotes: 1