Closed megel closed 2 years ago
That's a cool VSCode extension!
The code here is C# (not Jscript). Would a nuget.org package work?
Our plan for distribution is to use the Power Apps CLI. (https://docs.microsoft.com/en-us/powerapps/developer/data-platform/powerapps-cli)
@MikeStall thanks. Currently I have included a setting in my VSCode Extension which can be configured to the path of PASopa.exe
:
For this you need to clone your repository and build the PASopa.exe
. This works fine for, but is not comfortable for the users. Especially, when the device uses not a Windows OS. Furthermore I need to frequently pull this repository to get an actual release.
For these reasons I'm looking for a better way to include the PASopa.exe
into installation & upgrade process of my VSCode Extension.
Do you have any idea - how I can improve this? Can I trigger the installation of Power Apps CLI? Is the PASopa.exe
added to Path-Variable, when the Power Apps CLI is installed? Does this also work e.g. on MacOS?
@megel - would pulling a built binary from nuget.org work for you?
This should work on MacOs,Linux, etc with the recent PR from #177 .
@MikeStall this might work. Do you have an example how-to download and include the nuget package in github CI build?
Here's an example of how to download pac using Azure DevOps PowerShell tasks.
steps:
- powershell: |
$nugetPackage = "Microsoft.PowerApps.CLI"
$nugetPackageVersion = "1.5.3"
$outFolder = "pac"
nuget install $nugetPackage -Version $nugetPackageVersion -OutputDirectory $outFolder
$pacNugetFolder = Get-ChildItem $outFolder | Where-Object {$_.Name -match $nugetPackage + "."}
$pacPath = $pacNugetFolder.FullName + "\tools"
echo "##vso[task.setvariable variable=pacPath]$pacPath"
displayName: 'Install pac'
- powershell: |
$env:PATH = $env:PATH + ";" + "$(pacPath)"
pac auth create --url $(url) --tenant $(Tenant) --applicationId $(ApplicationId) --clientSecret $(ClientSecret)
pac solution list
displayName: 'run pac'
You could draw inspiration from above to port this to 1) GitHub yaml 2) change the code to download and call into the library pasopa.exe calls into.
https://www.nuget.org/packages/Microsoft.PowerPlatform.Formulas.Tools/
pasopa.exe isn't part of the nuget feed. However, you could call into it using PowerShell. https://activedirectoryfaq.com/2016/01/use-net-code-c-and-dlls-in-powershell/
This is how we plan on using it in our pipelines until pac has it natively.
So I've been trying this out today. Downloading the assemblies from nuget and calling into them via PowerShell is proving to be a pain due to all the dependent assemblies that also needed to be loaded. I've decided to move to just building my own version of pasopa.exe off of the assemblies from nuget.
I test currently a similar approach:
My Test: https://github.com/megel/TestBuild
Seams, I have the first part:
But now the big question - how do I call the PASopa with parameters at MacOS and Ubuntu?
Would this work:
.../bin/macos/PASopa -unpack powerapp.msapp out-folder-name
.../bin/ubuntu/PASopa -unpack powerapp.msapp out-folder-name
.../bin/windows/PASopa.exe -unpack powerapp.msapp out-folder-name
this should work :)
@megel - Can your project just reference the nuget package? https://www.nuget.org/packages/Microsoft.PowerPlatform.Formulas.Tools/0.2.1-preview
And then call into it the same way that pasopa does? https://github.com/microsoft/PowerApps-Language-Tooling/blob/master/src/PASopa/Program.cs
Your tool would then include a copy of that dll as part of your tool and distribution.
@MikeStall sorry for the late answer.
Well using this nuget package is fine for me on my local computer where all dependent assemblies are present. I can use PowerShell or TypeScript.
But in a pipeline, this becomes a nightmare because of "Could not load file or assembly ...." like:
Unpack D:\a\1\s\src\CanvasApps\ccppi_gppbootcamp2021_d82c0_DocumentUri.msapp --> D:\a\1\s\src\CanvasApps\ccppi_gppbootcamp2021_d82c0_DocumentUri_msapp_src
Load D:\a\1\s\src\CanvasApps\ccppi_gppbootcamp2021_d82c0_DocumentUri.msapp
(, Error PA3001: Internal error. Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
1 errors, 0 warnings.
)
Save to sources D:\a\1\s\src\CanvasApps\ccppi_gppbootcamp2021_d82c0_DocumentUri_msapp_src
(, Error PA3001: Internal error. Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
1 errors, 0 warnings.
)
ForEach-Object : Method invocation failed because
[System.ValueTuple`2[[Microsoft.PowerPlatform.Formulas.Tools.CanvasDocument, Microsoft.PowerPlatform.Formulas.Tools,
Version=0.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35],[Microsoft.PowerPlatform.Formulas.Tools.ErrorContainer,
Microsoft.PowerPlatform.Formulas.Tools, Version=0.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]] does not
contain a method named 'SaveToSources'.
The PowerShell works fine, but the dependencies on a Build Agent in Azure DevOps (Microsoft-Hosted & windows-latest) during Save & Load is horrible.
Get-ChildItem "$searchPath" -Filter 'Microsoft.PowerPlatform.Formulas.Tools.dll' -Recurse | ForEach-Object { Add-Type -Path $_.FullName }
$result = [Microsoft.PowerPlatform.Formulas.Tools.CanvasDocument]::LoadFromMsapp($sourcePath)
$outDir = $sourcePath.Substring(0, $sourcePath.Length - 6) + "_src"
Write-Host("Unpack: $sourcePath --> $outDir ");
$msApp = $result[0]
$errors = $result[1]
if ($errors.HasErrors) {
Write-Error $errors
}
$errors = $msApp.SaveToSources($targetPath);
For my own vs-code extension, I have decided to import and build this repo. This works fine.
Maybe you can add all dependencies to the nuget or you should reference other packages as well.
For the nuget, you'd need to do a proper nuget restore so that it downloads the dll dependencies.
Alternatively, we will soon be shipping in https://docs.microsoft.com/en-us/powerapps/developer/data-platform/powerapps-cli,
If you're looking to run in browser, this may be a good resource: https://dotnet.microsoft.com/en-us/apps/aspnet/web-apps/blazor
Hi, is there a chance to get the Power Apps Solution Packer as Node.js package or Artifact?
I want to include a dependency to the newest release in my VSCode Extension: https://github.com/megel/powerapps-helper https://marketplace.visualstudio.com/items?itemName=megel.mme2k-powerapps-helper