-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #73 from onikolaiev/develop
Add Power Platform Unified Package creation functionality
- Loading branch information
Showing
26 changed files
with
620 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
--- | ||
external help file: fscps.tools-help.xml | ||
Module Name: fscps.tools | ||
online version: | ||
schema: 2.0.0 | ||
--- | ||
|
||
# Update-FSCPSNugetsFromLCS | ||
|
||
## SYNOPSIS | ||
This uploads the D365FSC nugets from the LCS to the active storage account | ||
|
||
## SYNTAX | ||
|
||
``` | ||
Update-FSCPSNugetsFromLCS [[-LCSUserName] <String>] [[-LCSUserPassword] <SecureString>] | ||
[[-LCSProjectId] <String>] [[-LCSClientId] <String>] [[-FSCMinimumVersion] <String>] | ||
[-ProgressAction <ActionPreference>] [<CommonParameters>] | ||
``` | ||
|
||
## DESCRIPTION | ||
This uploads the D365FSC nugets from the LCS to the active NuGet storage account | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
``` | ||
Update-FSCPSNugetsFromLCS -LCSUserName "[email protected]" -LCSUserPassword "superSecureString" -LCSProjectId "123456" -LCSClientId "123ebf68-a86d-4392-ae38-57b2172ee789" -FSCMinimumVersion "10.0.38" | ||
``` | ||
|
||
this will uploads the D365FSC nugets from the LCS to the active storage account | ||
|
||
## PARAMETERS | ||
|
||
### -LCSUserName | ||
The LCS username | ||
|
||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 1 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -LCSUserPassword | ||
The LCS password | ||
```yaml | ||
Type: SecureString | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 2 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -LCSProjectId | ||
The LCS project ID | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 3 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -LCSClientId | ||
The ClientId what has access to the LCS | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 4 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -FSCMinimumVersion | ||
The minimum version of the FSC to update the NuGet\`s | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Aliases: | ||
|
||
Required: False | ||
Position: 5 | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -ProgressAction | ||
{{ Fill ProgressAction Description }} | ||
```yaml | ||
Type: ActionPreference | ||
Parameter Sets: (All) | ||
Aliases: proga | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### CommonParameters | ||
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). | ||
## INPUTS | ||
## OUTPUTS | ||
## NOTES | ||
Author: Oleksandr Nikolaiev (@onikolaiev) | ||
## RELATED LINKS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
|
||
<# | ||
.SYNOPSIS | ||
This uploads the D365FSC nugets from the LCS to the active storage account | ||
.DESCRIPTION | ||
This uploads the D365FSC nugets from the LCS to the active NuGet storage account | ||
.PARAMETER LCSUserName | ||
The LCS username | ||
.PARAMETER LCSUserPassword | ||
The LCS password | ||
.PARAMETER LCSProjectId | ||
The LCS project ID | ||
.PARAMETER LCSClientId | ||
The ClientId what has access to the LCS | ||
.PARAMETER FSCMinimumVersion | ||
The minimum version of the FSC to update the NuGet`s | ||
.EXAMPLE | ||
PS C:\> Update-FSCPSNugetsFromLCS -LCSUserName "[email protected]" -LCSUserPassword "superSecureString" -LCSProjectId "123456" -LCSClientId "123ebf68-a86d-4392-ae38-57b2172ee789" -FSCMinimumVersion "10.0.38" | ||
this will uploads the D365FSC nugets from the LCS to the active storage account | ||
.NOTES | ||
Author: Oleksandr Nikolaiev (@onikolaiev) | ||
#> | ||
function Update-FSCPSNugetsFromLCS { | ||
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")] | ||
[CmdletBinding()] | ||
param( | ||
[Parameter()] | ||
[string]$LCSUserName, | ||
[Parameter()] | ||
[SecureString]$LCSUserPassword, | ||
[Parameter()] | ||
[string]$LCSProjectId, | ||
[Parameter()] | ||
[string]$LCSClientId, | ||
[Parameter()] | ||
[string]$FSCMinimumVersion | ||
) | ||
|
||
begin{ | ||
Invoke-TimeSignal -Start | ||
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($LCSUserPassword) | ||
$UnsecureLCSUserPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) | ||
|
||
Get-D365LcsApiToken -ClientId $LCSClientId -Username $LCSUserName -Password $UnsecureLCSUserPassword -LcsApiUri "https://lcsapi.lcs.dynamics.com" | Set-D365LcsApiConfig -ProjectId $LCSProjectId -ClientId $LCSClientId | ||
|
||
} | ||
process{ | ||
|
||
try | ||
{ | ||
|
||
Get-D365LcsApiConfig | ||
$assetList = Get-D365LcsSharedAssetFile -FileType NuGetPackage | ||
|
||
$assetList | Sort-Object{$_.ModifiedDate} | ForEach-Object { | ||
#$fileName = $_.FileName | ||
|
||
$fscVersion = Get-FSCVersionFromPackageName $_.Name | ||
if($fscVersion -gt $FSCMinimumVersion -and $fscVersion.Length -gt 6) | ||
{ | ||
Write-PSFMessage -Level Host -Message "#################### $fscVersion #####################" | ||
try | ||
{ | ||
#ProcessingNuGet -FSCVersion $fscVersion -AssetId $_.Id -AssetName $fileName -ProjectId $lcsProjectId -LCSToken $lcstoken -StorageSAStoken $StorageSAStoken -LCSAssetName $_.Name | ||
} | ||
catch | ||
{ | ||
$_.Exception.Message | ||
} | ||
} | ||
} | ||
|
||
<# | ||
$assetList = Get-D365LcsSharedAssetFile -FileType NuGetPackage | ||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | ||
$destinationNugetFilePath = Join-Path $PackageDestination $AssetName | ||
#get download link asset | ||
$uri = "https://lcsapi.lcs.dynamics.com/box/fileasset/GetFileAsset/$($ProjectId)?assetId=$($AssetId)" | ||
$assetJson = (Invoke-RestMethod -Method Get -Uri $uri -Headers $header) | ||
if(Test-Path $destinationNugetFilePath) | ||
{ | ||
$regex = [regex] "\b(([0-9]*[0-9])\.){3}(?:[0-9]*[0-9]?)\b" | ||
$filenameVersion = $regex.Match($AssetName).Value | ||
$version = Get-NuGetVersion $destinationNugetFilePath | ||
if($filenameVersion -ne "") | ||
{ | ||
$newdestinationNugetFilePath = ($destinationNugetFilePath).Replace(".$filenameVersion.nupkg", ".nupkg") | ||
} | ||
else { $newdestinationNugetFilePath = $destinationNugetFilePath } | ||
$newdestinationNugetFilePath = ($newdestinationNugetFilePath).Replace(".nupkg",".$version.nupkg") | ||
if(-not(Test-Path $newdestinationNugetFilePath)) | ||
{ | ||
Rename-Item -Path $destinationNugetFilePath -NewName ([System.IO.DirectoryInfo]$newdestinationNugetFilePath).FullName -Force -PassThru | ||
} | ||
$destinationNugetFilePath = $newdestinationNugetFilePath | ||
} | ||
$download = (-not(Test-Path $destinationNugetFilePath)) | ||
$blob = Get-AzStorageBlob -Context $ctx -Container $storageContainer -Blob $AssetName -ConcurrentTaskCount 10 -ErrorAction SilentlyContinue | ||
if(!$blob) | ||
{ | ||
if($download) | ||
{ | ||
Invoke-D365AzCopyTransfer -SourceUri $assetJson.FileLocation -DestinationUri "$destinationNugetFilePath" | ||
if(Test-Path $destinationNugetFilePath) | ||
{ | ||
$regex = [regex] "\b(([0-9]*[0-9])\.){3}(?:[0-9]*[0-9]?)\b" | ||
$filenameVersion = $regex.Match($AssetName).Value | ||
$version = Get-NuGetVersion $destinationNugetFilePath | ||
if($filenameVersion -ne "") | ||
{ | ||
$newdestinationNugetFilePath = ($destinationNugetFilePath).Replace(".$filenameVersion.nupkg", ".nupkg") | ||
} | ||
else { $newdestinationNugetFilePath = $destinationNugetFilePath } | ||
$newdestinationNugetFilePath = ($newdestinationNugetFilePath).Replace(".nupkg",".$version.nupkg") | ||
if(-not(Test-Path $newdestinationNugetFilePath)) | ||
{ | ||
Rename-Item -Path $destinationNugetFilePath -NewName ([System.IO.DirectoryInfo]$newdestinationNugetFilePath).FullName -Force -PassThru | ||
} | ||
$destinationNugetFilePath = $newdestinationNugetFilePath | ||
} | ||
#Invoke-D365AzCopyTransfer $assetJson.FileLocation "$destinationNugetFilePath" | ||
} | ||
} | ||
else | ||
{ | ||
if($download) | ||
{ | ||
$blob = Get-AzStorageBlobContent -Context $ctx -Container $storageContainer -Blob $AssetName -Destination $destinationNugetFilePath -ConcurrentTaskCount 10 -Force | ||
$blob.Name | ||
} | ||
Write-PSFMessage -Level Host "Blob was found!" | ||
} | ||
$regex = [regex] "\b(([0-9]*[0-9])\.){3}(?:[0-9]*[0-9]?)\b" | ||
$filenameVersion = $regex.Match($AssetName).Value | ||
$version = Get-NuGetVersion $destinationNugetFilePath | ||
$AssetName = ($AssetName).Replace(".$filenameVersion.nupkg", ".nupkg") | ||
$AssetName = ($AssetName).Replace(".nupkg",".$version.nupkg") | ||
Write-PSFMessage -Level Host "FSCVersion: $FSCVersion" | ||
Write-PSFMessage -Level Host "AssetName: $AssetName" | ||
Set-AzStorageBlobContent -Context $ctx -Container $storageContainer -Blob "$AssetName" -File "$destinationNugetFilePath" -StandardBlobTier Hot -ConcurrentTaskCount 10 -Force | ||
#> | ||
|
||
|
||
} | ||
catch { | ||
Write-PSFMessage -Level Host -Message "Something went wrong while updating D365FSC package versiob" -Exception $PSItem.Exception | ||
Stop-PSFFunction -Message "Stopping because of errors" -EnableException $true | ||
return | ||
} | ||
finally{ | ||
|
||
} | ||
|
||
} | ||
end{ | ||
Invoke-TimeSignal -End | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.