From 833ca9fb915977c942ce3a752a2a48ca2a3042a6 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Thu, 8 Jul 2021 14:36:26 +0100 Subject: [PATCH] Build script - tweaks and fixes Hit this issue... https://docs.microsoft.com/en-us/dotnet/core/tools/sdk-errors/netsdk1005 Replaced the old "vswhere.exe" and MSBuild.exe calls with `dotnet` cli. Removed the Umbraco package XML manifest - no longer needed. --- .gitignore | 5 +- build/build-assets.ps1 | 6 -- build/build-pkgs.ps1 | 97 +++++-------------- build/manifest-nuget-core.nuspec | 8 +- build/manifest-umbraco.xml | 37 ------- .../Umbraco.Community.Contentment.csproj | 2 +- 6 files changed, 29 insertions(+), 126 deletions(-) delete mode 100644 build/manifest-umbraco.xml diff --git a/.gitignore b/.gitignore index 77bfbedd..1d3edc2e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,5 @@ artifacts/ build/assets/ src/packages/*/** /tools/*.exe -/build/__umb/* -/build/__nuget/* -/build/build-push.ps1 +/build/build-push-nuget.ps1 +/build/build-push-umb.ps1 diff --git a/build/build-assets.ps1 b/build/build-assets.ps1 index 062c44d5..cdf9ed1f 100644 --- a/build/build-assets.ps1 +++ b/build/build-assets.ps1 @@ -29,12 +29,6 @@ if (Test-Path -Path $targetFolder) { Remove-Item -Recurse -Force $targetFolder; } -# Copy DLL / PDB -$binFolder = "${targetFolder}\bin\Debug\net5.0"; - -if (!(Test-Path -Path $binFolder)) {New-Item -Path $binFolder -Type Directory;} -Copy-Item -Path "${TargetDir}${ProjectName}.*" -Destination $binFolder; - # Copy package front-end files assets $pluginFolder = "${targetFolder}\App_Plugins\Contentment\"; if (!(Test-Path -Path $pluginFolder)) {New-Item -Path $pluginFolder -Type Directory;} diff --git a/build/build-pkgs.ps1 b/build/build-pkgs.ps1 index 5d26d696..5623f3b0 100644 --- a/build/build-pkgs.ps1 +++ b/build/build-pkgs.ps1 @@ -8,17 +8,12 @@ $nugetPackageId = 'Our.Umbraco.Community.Contentment'; $projectNamespace = 'Umbraco.Community.Contentment'; -$packageName = 'Contentment'; -$nugetTitle = "${packageName} for Umbraco"; -$packageDescription = "${packageName}, a collection of components for Umbraco 8."; +$nugetTitle = "Contentment for Umbraco"; +$packageDescription = "Contentment, a collection of components for Umbraco."; $packageUrl = 'https://github.com/leekelleher/umbraco-contentment'; -$iconUrl = 'https://raw.githubusercontent.com/leekelleher/umbraco-contentment/master/docs/assets/img/logo.png'; -$licenseName = 'Mozilla Public License Version 2.0'; -$licenseUrl = 'https://mozilla.org/MPL/2.0/'; $authorName = 'Lee Kelleher'; -$authorUrl = 'https://leekelleher.com/'; -$minUmbracoVersion = 8,14,0; -$copyright = "Copyright " + [char]0x00A9 + " " + (Get-Date).year + " $authorName"; +$minUmbracoVersion = "9.0.0-rc001"; +$copyright = "" + [char]0x00A9 + " " + (Get-Date).year + " $authorName"; $tags = "umbraco"; $rootFolder = (Get-Item($MyInvocation.MyCommand.Path)).Directory.Parent.FullName; @@ -32,84 +27,36 @@ $csprojXml = [xml](Get-Content -Path "${srcFolder}\${projectNamespace}\${project $version = $csprojXml.Project.PropertyGroup.Version; Write-Host "Package version: $version"; -# Build the VS project - -# Ensure NuGet.exe -$nuget_exe = "${rootFolder}\tools\nuget.exe"; -If (-NOT(Test-Path -Path $nuget_exe)) { - Write-Host "Retrieving nuget.exe..."; - Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile $nuget_exe; -} -# vswhere.exe is part of VS2017 (v15.2)+ -$vswhere_exe = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"; - -$msbuild_exe = & "$vswhere_exe" -Latest -Requires Microsoft.Component.MSBuild -Find MSBuild\**\Bin\MSBuild.exe | Select-Object -First 1 -if (-NOT(Test-Path $msbuild_exe)) { - throw 'MSBuild not found!'; -} - -Write-Host 'Restoring NuGet packages...'; -& $nuget_exe restore "${srcFolder}\${projectNamespace}.sln"; +# Build the VS project +Write-Host 'Cleaning Visual Studio solution.'; +& dotnet clean "${srcFolder}\${projectNamespace}.sln"; Write-Host 'Compiling Visual Studio solution.'; -& $msbuild_exe "${srcFolder}\${projectNamespace}.sln" /p:Configuration=Release +& dotnet build "${srcFolder}\${projectNamespace}.sln" --configuration Release if (-NOT $?) { - throw 'The MSBuild process returned an error code.'; + throw 'The dotnet CLI returned an error code.'; } -# Populate the Umbraco package manifest - -$umbFolder = Join-Path -Path $buildFolder -ChildPath "__umb"; -if (!(Test-Path -Path $umbFolder)) {New-Item -Path $umbFolder -Type Directory;} - -$umbracoManifest = Join-Path -Path $buildFolder -ChildPath "manifest-umbraco.xml"; -$umbracoPackageXml = [xml](Get-Content $umbracoManifest); -$umbracoPackageXml.umbPackage.info.package.version = "$($version)"; -$umbracoPackageXml.umbPackage.info.package.name = $packageName; -$umbracoPackageXml.umbPackage.info.package.iconUrl = $iconUrl; -$umbracoPackageXml.umbPackage.info.package.license.set_InnerText($licenseName); -$umbracoPackageXml.umbPackage.info.package.license.url = $licenseUrl; -$umbracoPackageXml.umbPackage.info.package.url = $packageUrl; -$umbracoPackageXml.umbPackage.info.package.requirements.major = "$($minUmbracoVersion[0])"; -$umbracoPackageXml.umbPackage.info.package.requirements.minor = "$($minUmbracoVersion[1])"; -$umbracoPackageXml.umbPackage.info.package.requirements.patch = "$($minUmbracoVersion[2])"; -$umbracoPackageXml.umbPackage.info.author.name = $authorName; -$umbracoPackageXml.umbPackage.info.author.website = $authorUrl; -$umbracoPackageXml.umbPackage.info.readme."#cdata-section" = $packageDescription; - -$filesXml = $umbracoPackageXml.CreateElement("files"); +# Copy DLL to assets folder +$binFolder = "${assetsFolder}\bin"; +if (!(Test-Path -Path $binFolder)) {New-Item -Path $binFolder -Type Directory;} +Copy-Item -Path "${srcFolder}\${projectNamespace}\bin\Release\net5.0\${projectNamespace}.dll" -Destination $binFolder; -$assetFiles = Get-ChildItem -Path $assetsFolder -File -Recurse; -foreach($assetFile in $assetFiles){ - - $hash = Get-FileHash -Path $assetFile.FullName -Algorithm MD5; - $guid = $hash.Hash.ToLower() + $assetFile.Extension; - $orgPath = "~" + $assetFile.Directory.FullName.Replace($assetsFolder, "").Replace("\", "/"); - - $fileXml = $umbracoPackageXml.CreateElement("file"); - $fileXml.set_InnerXML("${guid}${orgPath}$($assetFile.Name)"); - $filesXml.AppendChild($fileXml); - - Copy-Item -Path $assetFile.FullName -Destination "${umbFolder}\${guid}"; -} - -$umbracoPackageXml.umbPackage.ReplaceChild($filesXml, $umbracoPackageXml.SelectSingleNode("/umbPackage/files")) | Out-Null; -$umbracoPackageXml.Save("${umbFolder}\package.xml"); +# Ensure the artifacts folder $artifactsFolder = Join-Path -Path $rootFolder -ChildPath "artifacts"; if (!(Test-Path -Path $artifactsFolder)) {New-Item -Path $artifactsFolder -Type Directory;} -Compress-Archive -Path "${umbFolder}\*" -DestinationPath "${artifactsFolder}\Contentment_$version.zip" -Force; +# Ensure NuGet.exe +$nuget_exe = "${rootFolder}\tools\nuget.exe"; +If (-NOT(Test-Path -Path $nuget_exe)) { + Write-Host "Retrieving nuget.exe..."; + Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -OutFile $nuget_exe; +} # Populate the NuGet package manifest - Copy-Item -Path "${rootFolder}\docs\assets\img\logo.png" -Destination "${assetsFolder}\icon.png"; -& $nuget_exe pack "${buildFolder}\manifest-nuget-core.nuspec" -BasePath $assetsFolder -OutputDirectory $artifactsFolder -Version "$version" -Properties "id=$nugetPackageId;version=$version;title=$nugetTitle;authors=$authorName;owners=$authorName;projectUrl=$packageUrl;requireLicenseAcceptance=false;description=$packageDescription;copyright=$copyright;license=MPL-2.0;language=en;tags=$tags;minUmbracoVersion=$($minUmbracoVersion[0]).$($minUmbracoVersion[1]).$($minUmbracoVersion[2]);repositoryUrl=$packageUrl;" -& $nuget_exe pack "${buildFolder}\manifest-nuget-web.nuspec" -BasePath $assetsFolder -OutputDirectory $artifactsFolder -Version "$version" -Properties "id=$nugetPackageId;version=$version;title=$nugetTitle;authors=$authorName;owners=$authorName;projectUrl=$packageUrl;requireLicenseAcceptance=false;description=$packageDescription;copyright=$copyright;license=MPL-2.0;language=en;tags=$tags;minUmbracoVersion=$($minUmbracoVersion[0]).$($minUmbracoVersion[1]).$($minUmbracoVersion[2]);repositoryUrl=$packageUrl;" - - -# Tidy up folders -Remove-Item -Recurse -Force $umbFolder; - +& $nuget_exe pack "${buildFolder}\manifest-nuget-core.nuspec" -BasePath $assetsFolder -OutputDirectory $artifactsFolder -Version "$version" -Properties "id=$nugetPackageId;version=$version;title=$nugetTitle;authors=$authorName;owners=$authorName;projectUrl=$packageUrl;requireLicenseAcceptance=false;description=$packageDescription;copyright=$copyright;license=MPL-2.0;language=en;tags=$tags;minUmbracoVersion=$minUmbracoVersion;repositoryUrl=$packageUrl;" +& $nuget_exe pack "${buildFolder}\manifest-nuget-web.nuspec" -BasePath $assetsFolder -OutputDirectory $artifactsFolder -Version "$version" -Properties "id=$nugetPackageId;version=$version;title=$nugetTitle;authors=$authorName;owners=$authorName;projectUrl=$packageUrl;requireLicenseAcceptance=false;description=$packageDescription;copyright=$copyright;license=MPL-2.0;language=en;tags=$tags;minUmbracoVersion=$minUmbracoVersion;repositoryUrl=$packageUrl;" diff --git a/build/manifest-nuget-core.nuspec b/build/manifest-nuget-core.nuspec index ecfd2a75..486dbee5 100644 --- a/build/manifest-nuget-core.nuspec +++ b/build/manifest-nuget-core.nuspec @@ -16,14 +16,14 @@ $tags$ - - - + + + - + \ No newline at end of file diff --git a/build/manifest-umbraco.xml b/build/manifest-umbraco.xml deleted file mode 100644 index d050e5aa..00000000 --- a/build/manifest-umbraco.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - 0.0.0 - - - - - 0 - 0 - 0 - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Umbraco.Community.Contentment/Umbraco.Community.Contentment.csproj b/src/Umbraco.Community.Contentment/Umbraco.Community.Contentment.csproj index 08da7e60..5b5172cf 100644 --- a/src/Umbraco.Community.Contentment/Umbraco.Community.Contentment.csproj +++ b/src/Umbraco.Community.Contentment/Umbraco.Community.Contentment.csproj @@ -1,6 +1,6 @@  - net5.0 + net5.0 Umbraco.Community.Contentment Our.Umbraco.Community.Contentment Contentment for Umbraco