From b4a34393a05469adece295b420ce45f37ef55079 Mon Sep 17 00:00:00 2001 From: "J.F. Larente" Date: Thu, 14 Jun 2018 08:44:27 -0400 Subject: [PATCH 1/2] - Parameterized WebRoot (to avoid having to change it in multiple locations) - Added assets folder and changed paths to point to the new folder (keeps the 9.0.1 Commerce-level folder cleaner) --- .gitignore | 2 + .../Deploy-Sitecore-Commerce.ps1 | 48 +++++++++---------- 9.0/9.0.1 Commerce/assets/readme.txt | 1 + 3 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 9.0/9.0.1 Commerce/assets/readme.txt diff --git a/.gitignore b/.gitignore index 66e784b..a4e4cc8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.log *.InstallLog +/.vs +/9.0/9.0.1 Commerce/assets diff --git a/9.0/9.0.1 Commerce/SIF.Sitecore.Commerce/Deploy-Sitecore-Commerce.ps1 b/9.0/9.0.1 Commerce/SIF.Sitecore.Commerce/Deploy-Sitecore-Commerce.ps1 index 8e209b6..28fe791 100644 --- a/9.0/9.0.1 Commerce/SIF.Sitecore.Commerce/Deploy-Sitecore-Commerce.ps1 +++ b/9.0/9.0.1 Commerce/SIF.Sitecore.Commerce/Deploy-Sitecore-Commerce.ps1 @@ -22,7 +22,7 @@ param( [string]$SqlDbPrefix = $Prefix, [string]$CommerceSearchProvider = "SOLR", [string]$CommerceSiteName = "$Prefix.commerce", - [string]$Drive = $($Env:SYSTEMDRIVE), + [string]$WebRoot = "C:\inetpub\wwwroot", [string]$XConnectSiteHostHeaderName = "$($Prefix).xconnect", [string]$SolrUrl = "https://localhost:8983/solr", [string]$SolrInstallDir = "C:/tools/solr-6.6.2", @@ -69,8 +69,8 @@ $params = @{ # CM instance and XConnect settings SiteName = $SiteName SiteHostHeader = $siteHostHeader - SiteInstallDir = "$($Drive)\inetpub\wwwroot\$Prefix.local" - XConnectInstallDir = "$($Drive)\inetpub\wwwroot\$Prefix.xconnect" + SiteInstallDir = "$(Join-Path $WebRoot $Prefix.local)" + XConnectInstallDir = "$(Join-Path $WebRoot $Prefix.xconnect)" # SQL SqlCommerceServicesDbName = "$($Prefix)_SitecoreCommerce_SharedEnvironments" @@ -83,42 +83,42 @@ $params = @{ CommerceAuthoring = "$CommerceSiteName-authoring" CommerceAuthoringCertificateDnsName = "*.$Prefix.local" CommerceAuthoringCertificateName = "all.$Prefix.local" - CommerceAuthoringDir = "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\$CommerceSiteName-authoring" + CommerceAuthoringDir = "$(Join-Path $WebRoot $('{0}-authoring' -f $CommerceSiteName))" CommerceAuthoringHostHeader = "commerce-authoring.$SiteName" CommerceAuthoringServicesPort = "443" CommerceMinions = "$CommerceSiteName-minions" CommerceMinionsCertificateDnsName = "*.$Prefix.local" CommerceMinionsCertificateName = "all.$Prefix.local" - CommerceMinionsDir = "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\$CommerceSiteName-minions" + CommerceMinionsDir = "$(Join-Path $WebRoot $('{0}-minions' -f $CommerceSiteName))" CommerceMinionsHostHeader = "commerce-minions.$SiteName" CommerceMinionsServicesPort = "443" CommerceOps = "$CommerceSiteName-ops" CommerceOpsCertificateDnsName = "*.$Prefix.local" CommerceOpsCertificateName = "all.$Prefix.local" - CommerceOpsDir = "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\$CommerceSiteName-ops" + CommerceOpsDir = "$(Join-Path $WebRoot $('{0}-ops' -f $CommerceSiteName))" CommerceOpsHostHeader = "commerce-ops.$SiteName" CommerceOpsServicesPort = "443" CommerceShops = "$CommerceSiteName-shops" CommerceShopsCertificateDnsName = "*.$Prefix.local" CommerceShopsCertificateName = "all.$Prefix.local" - CommerceShopsDir = "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\$CommerceSiteName-shops" + CommerceShopsDir = "$(Join-Path $WebRoot $('{0}-shops' -f $CommerceSiteName))" CommerceShopsHostHeader = "commerce-shops.$SiteName" CommerceShopsServicesPort = "443" SitecoreIdentityServer = "$CommerceSiteName-identity" SitecoreIdentityServerCertificateDnsName = "*.$Prefix.local" SitecoreIdentityServerCertificateName = "all.$Prefix.local" - SitecoreIdentityServerDir = "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\$CommerceSiteName-identity" + SitecoreIdentityServerDir = "$(Join-Path $WebRoot $('{0}-identity' -f $CommerceSiteName))" SitecoreIdentityServerHostHeader = "identity.$SiteName" SitecoreIdentityServerServicesPort = "443" SitecoreBizFx = "$CommerceSiteName-bizfx" SitecoreBizFxCertificateDnsName = "*.$Prefix.local" SitecoreBizFxCertificateName = "all.$Prefix.local" - SitecoreBizFxDir = "$($Env:SYSTEMDRIVE)\inetpub\wwwroot\$CommerceSiteName-bizfx" + SitecoreBizFxDir = "$(Join-Path $WebRoot $('{0}-bizfx' -f $CommerceSiteName))" SitecoreBizFxHostHeader = "bizfx.$SiteName" SitecoreBizFxServicesPort = "443" @@ -127,24 +127,24 @@ $params = @{ CommerceEngineCertificateName = $CommerceSiteName # Packages - PackageAdventureWorksImagesPath = Resolve-Path -Path "..\Adventure Works Images.zip" - PackageCEConnectPath = Resolve-Path -Path "..\Sitecore.Commerce.Engine.Connect*.update" - PackageCommerceConnectPath = Resolve-Path -Path "..\Sitecore Commerce Connect*.zip" - PackageCommerceEngineDacPacPath = Resolve-Path -Path "..\Sitecore.Commerce.Engine.SDK.2.1.10\Sitecore.Commerce.Engine.DB.dacpac" - PackageHabitatImagesPath = Resolve-Path -Path "..\Sitecore.Commerce.Habitat.Images-*.zip" - PackagePowerShellExtensionsPath = Resolve-Path -Path "..\Sitecore PowerShell Extensions-4.7.2 for Sitecore 8.zip" - PackageSitecoreBizFxServicesContentDir = Resolve-Path -Path "..\Sitecore.BizFX.1.1.9" - PackageSitecoreCommerceEnginePath = Resolve-Path -Path "..\Sitecore.Commerce.Engine.2.*.zip" - PackageSitecoreIdentityServerPath = Resolve-Path -Path "..\Sitecore.IdentityServer.1.*.zip" - PackageSXACommercePath = Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator 1.*.zip" - PackageSXAPath = Resolve-Path -Path "..\Sitecore Experience Accelerator 1.7 rev. 180410 for 9.0.zip" - PackageSXAStorefrontCatalogPath = Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator Habitat Catalog*.zip" - PackageSXAStorefrontPath = Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator Storefront 1.*.zip" - PackageSXAStorefrontThemePath = Resolve-Path -Path "..\Sitecore Commerce Experience Accelerator Storefront Themes*.zip" + PackageAdventureWorksImagesPath = Resolve-Path -Path "..\assets\Adventure Works Images.zip" + PackageCEConnectPath = Resolve-Path -Path "..\assets\Sitecore.Commerce.Engine.Connect*.update" + PackageCommerceConnectPath = Resolve-Path -Path "..\assets\Sitecore Commerce Connect*.zip" + PackageCommerceEngineDacPacPath = Resolve-Path -Path "..\assets\Sitecore.Commerce.Engine.SDK.2.1.10\Sitecore.Commerce.Engine.DB.dacpac" + PackageHabitatImagesPath = Resolve-Path -Path "..\assets\Sitecore.Commerce.Habitat.Images-*.zip" + PackagePowerShellExtensionsPath = Resolve-Path -Path "..\assets\Sitecore PowerShell Extensions-4.7.2 for Sitecore 8.zip" + PackageSitecoreBizFxServicesContentDir = Resolve-Path -Path "..\assets\Sitecore.BizFX.1.1.9" + PackageSitecoreCommerceEnginePath = Resolve-Path -Path "..\assets\Sitecore.Commerce.Engine.2.*.zip" + PackageSitecoreIdentityServerPath = Resolve-Path -Path "..\assets\Sitecore.IdentityServer.1.*.zip" + PackageSXACommercePath = Resolve-Path -Path "..\assets\Sitecore Commerce Experience Accelerator 1.*.zip" + PackageSXAPath = Resolve-Path -Path "..\assets\Sitecore Experience Accelerator 1.7 rev. 180410 for 9.0.zip" + PackageSXAStorefrontCatalogPath = Resolve-Path -Path "..\assets\Sitecore Commerce Experience Accelerator Habitat Catalog*.zip" + PackageSXAStorefrontPath = Resolve-Path -Path "..\assets\Sitecore Commerce Experience Accelerator Storefront 1.*.zip" + PackageSXAStorefrontThemePath = Resolve-Path -Path "..\assets\Sitecore Commerce Experience Accelerator Storefront Themes*.zip" # Tools ToolsSiteUtilitiesDir = ( Join-Path -Path $DEPLOYMENT_DIRECTORY -ChildPath "SiteUtilityPages" ) - ToolsMergeToolPath = Resolve-Path -Path "..\msbuild.microsoft.visualstudio.web.targets.14.0.0.3\tools\VSToolsPath\Web\Microsoft.Web.XmlTransform.dll" + ToolsMergeToolPath = Resolve-Path -Path "..\assets\msbuild.microsoft.visualstudio.web.targets.14.0.0.3\tools\VSToolsPath\Web\Microsoft.Web.XmlTransform.dll" # Accounts SitecoreUsername = $SitecoreUsername diff --git a/9.0/9.0.1 Commerce/assets/readme.txt b/9.0/9.0.1 Commerce/assets/readme.txt new file mode 100644 index 0000000..7ec4301 --- /dev/null +++ b/9.0/9.0.1 Commerce/assets/readme.txt @@ -0,0 +1 @@ +Drop all files here as outlined in the installation documents \ No newline at end of file From 6abf76fbc9fff90be4e3ca67ba5c0ec1a4900743 Mon Sep 17 00:00:00 2001 From: "J.F. Larente" Date: Thu, 14 Jun 2018 12:30:08 -0400 Subject: [PATCH 2/2] Adding ability to download and extract the required packages automatically --- .gitignore | 2 + 9.0/9.0.1 Commerce/download-and-extract.ps1 | 206 ++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 9.0/9.0.1 Commerce/download-and-extract.ps1 diff --git a/.gitignore b/.gitignore index a4e4cc8..b4ab32a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ *.InstallLog /.vs /9.0/9.0.1 Commerce/assets +/9.0/9.0.1 Commerce/Downloads +/9.0/9.0.1 Commerce/dev.creds.xml diff --git a/9.0/9.0.1 Commerce/download-and-extract.ps1 b/9.0/9.0.1 Commerce/download-and-extract.ps1 new file mode 100644 index 0000000..28d3749 --- /dev/null +++ b/9.0/9.0.1 Commerce/download-and-extract.ps1 @@ -0,0 +1,206 @@ + +Param( + $DownloadFolder = "", #Defaults to .\assets\Downloads + $CommerceAssetFolder = "" #Defaults to .\assets + +) + + +$packagesToExtract = ('{"files":[ + { + "name": "SIF.Sitecore.Commerce", + "version": "1.1.4" + }, + { + "name": "Sitecore.Commerce.Engine", + "version": "2.1.55" + }, + { + "name": "Sitecore.BizFX", + "version": "1.1.9" + }, + { + "name": "Sitecore.Commerce.Engine.SDK", + "version": "2.1.10" + } + ]}') | ConvertFrom-Json + +if ($DownloadFolder -eq "" -or $DownloadFolder -eq $null) { + $DownloadFolder = Join-Path "$PWD" "Downloads" + if (!(Test-Path $DownloadFolder)) { + New-Item -ItemType Directory -Force -Path $DownloadFolder + } +} +if ($CommerceAssetFolder -eq "" -or $CommerceAssetFolder -eq $null) { + $CommerceAssetFolder = Join-Path "$PWD" "assets" +} + +Function Invoke-FetchSitecoreCredentials { + # Credit: https://jermdavis.wordpress.com/2017/11/27/downloading-stuff-from-dev-sitecore-net/ + $file = "dev.creds.xml" + + if (Test-Path ".\\$file") { + $cred = Import-Clixml ".\\$file" + } + else { + $cred = Get-Credential -Message "Enter your SDN download credentials:" + $cred | Export-Clixml ".\\$file" + } + + return $cred +} + +Function Invoke-FetchDownloadAuthentication($cred) { + # Credit: https://jermdavis.wordpress.com/2017/11/27/downloading-stuff-from-dev-sitecore-net/ + + $authUrl = "https://dev.sitecore.net/api/authorization" + + $pwd = $cred.GetNetworkCredential().Password + + $postParams = "{ ""username"":""$($cred.UserName)"", ""password"":""$pwd"" }" + + $authResponse = Invoke-WebRequest -Uri $authUrl -Method Post -ContentType "application/json;charset=UTF-8" -Body $postParams -SessionVariable webSession + $authCookies = $webSession.Cookies.GetCookies("https://sitecore.net") + + $marketPlaceCookie = $authCookies["marketplace_login"] + + if ([String]::IsNullOrWhiteSpace($marketPlaceCookie)) { + throw "Credentials appear invalid" + } + + $devUrl = "https://dev.sitecore.net" + + $devResponse = Invoke-WebRequest -Uri $devUrl -WebSession $webSession + $devCookies = $webSession.Cookies.GetCookies("https://dev.sitecore.net") + + $sessionCookie = $devCookies["ASP.Net_SessionId"] + + return "$marketPlaceCookie; $sessionCookie" +} + +function Invoke-SitecoreFileDownload { + [CmdletBinding()] + param ( + [Parameter(Mandatory)] + [string] $Uri, + + [Parameter(Mandatory)] + [string] $OutputFile, + + [string] $cookies + ) + # Credit: https://jermdavis.wordpress.com/2017/11/27/downloading-stuff-from-dev-sitecore-net/ + + $webClient = New-Object System.Net.WebClient + + if (!([String]::IsNullOrWhiteSpace($cookies))) { + $webClient.Headers.Add([System.Net.HttpRequestHeader]::Cookie, $cookie) + } + + $data = New-Object psobject -Property @{Uri = $Uri; OutputFile = $OutputFile} + + $changed = Register-ObjectEvent -InputObject $webClient -EventName DownloadProgressChanged -MessageData $data -Action { + Write-Progress -Activity "Downloading $($event.MessageData.Uri)" -Status "To $($event.MessageData.OutputFile)" -PercentComplete $eventArgs.ProgressPercentage + } + + try { + $handle = $webClient.DownloadFileAsync($Uri, $PSCmdlet.GetUnresolvedProviderPathFromPSPath($OutputFile)) + + while ($webClient.IsBusy) { + Start-Sleep -Milliseconds 1000 + } + } + finally { + Write-Progress -Activity "Downloading $Uri" -Completed + + Remove-Job $changed -Force + Get-EventSubscriber | Where SourceObject -eq $webClient | Unregister-Event -Force + } +} +Function Invoke-SitecoreDownload { + param( + [string]$url, + [string]$target + ) + + $cred = Invoke-FetchSitecoreCredentials + $cookie = Invoke-FetchDownloadAuthentication $cred + + Invoke-SitecoreFileDownload -Uri $url -OutputFile $target -Cookies $cookie + +} +Function Invoke-DownloadAndExtractAssets { + + + $CommercePackageUrl = "https://dev.sitecore.net/~/media/F08E9950D0134D1DA325801057C96B35.ashx" #Your download url here + $commercePackageFileName = "Sitecore.Commerce.2018.03-2.1.55.zip" + $commercePackageDestination = $([io.path]::combine($DownloadFolder, $commercePackageFileName)).ToString() + + Write-Host "Saving $CommercePackageUrl to $commercePackageDestination - if required" -ForegroundColor Green + if (!(Test-Path $commercePackageDestination)) { + Invoke-SitecoreDownload $CommercePackageUrl $commercePackageDestination + } + + + $sxaPackageUrl = "https://dev.sitecore.net/~/media/573443081B494E2B9D83D3208B549E49.ashx" + $sxaPackageDestination = $([io.path]::combine($CommerceAssetFolder, "Sitecore Experience Accelerator 1.7 rev. 180410 for 9.0.zip")) + if (!(Test-Path $sxaPackageDestination)) { + Invoke-SitecoreDownload $sxaPackageUrl $sxaPackageDestination + } + + $spePackageUrl = "https://marketplace.sitecore.net/services/~/download/3D2CADDAB4A34CEFB1CFD3DD86D198D5.ashx?data=Sitecore%20PowerShell%20Extensions-4.7.2%20for%20Sitecore%208&itemId=6aaea046-83af-4ef1-ab91-87f5f9c1aa57" + $spePackageDestination = $([io.path]::combine($CommerceAssetFolder, "Sitecore PowerShell Extensions-4.7.2 for Sitecore 8.zip")) + + if (!(Test-Path $spePackageDestination)) { + Invoke-SitecoreDownload $spePackageUrl $spePackageDestination + } + + $msbuildNuGetUrl = "https://www.nuget.org/api/v2/package/MSBuild.Microsoft.VisualStudio.Web.targets/14.0.0.3" + $msbuildNuGetPackageFileName = "msbuild.microsoft.visualstudio.web.targets.14.0.0.3.nupkg" + $msbuildNuGetPackageDestination = $([io.path]::combine($DownloadFolder, $msbuildNuGetPackageFileName)) + + Write-Host "Saving $msbuildNuGetUrl to $msbuildNuGetPackageDestination - if required" -ForegroundColor Green + if (!(Test-Path $msbuildNuGetPackageDestination)) { + Invoke-WebRequest -Uri $msbuildNuGetUrl -OutFile $msbuildNuGetPackageDestination + #Start-BitsTransfer -source $msbuildNuGetUrl -Destination $msbuildNuGetPackageDestination + } + $aspnetCoreGetUrl = "https://aka.ms/dotnetcore-2-windowshosting" + $aspnetCoreFileName = "DotNetCore.2.0.5-WindowsHosting.exe" + $aspnetPackageDestination = $([io.path]::combine($DownloadFolder, $aspnetCoreFileName)) + + Write-Host "Saving $aspnetCoreGetUrl to $aspnetPackageDestination - if required" -ForegroundColor Green + if (!(Test-Path $aspnetPackageDestination)) { + Start-BitsTransfer -source $aspnetCoreGetUrl -Destination $aspnetPackageDestination + } + + $netCoreSDKUrl = "https://download.microsoft.com/download/0/F/D/0FD852A4-7EA1-4E2A-983A-0484AC19B92C/dotnet-sdk-2.0.0-win-x64.exe" + $netCoreSDKFileName = "dotnet-sdk-2.0.0-win-x64.exe" + $netCoreSDKPackageDestination = $([io.path]::combine($DownloadFolder, $netCoreSDKFileName)) + + Write-Host "Saving $netCoreSDKUrl to $netCoreSDKPackageDestination - if required" -ForegroundColor Green + if (!(Test-Path $netCoreSDKPackageDestination)) { + Start-BitsTransfer -source $netCoreSDKUrl -Destination $netCoreSDKPackageDestination + } + + + Write-Host "Extracting to $($CommerceAssetFolder)" + set-alias sz "$env:ProgramFiles\7-zip\7z.exe" + sz x -o"$CommerceAssetFolder" $commercePackageDestination -y -aoa + + foreach ($package in $packagesToExtract.files) { + + $extract = Join-Path $CommerceAssetFolder $($package.name + "." + $package.version + ".zip") + $output = Join-Path $CommerceAssetFolder $($package.name + "." + $package.version) + + + sz x -o"$($output)" $extract -r -y -aoa + } + #Extract MSBuild nuget package + $extract = $(Join-Path $DownloadFolder "msbuild.microsoft.visualstudio.web.targets.14.0.0.3.nupkg") + $output = $(Join-Path $CommerceAssetFolder "msbuild.microsoft.visualstudio.web.targets.14.0.0.3") + sz x -o"$($output)" $extract -r -y -aoa + +} + + +Invoke-DownloadAndExtractAssets \ No newline at end of file