Netcore: Let build.ps1 create the dotnet new templates (#8591)

* Creates the Umbraco.Templates.nuspec on build

* Update nuspec to match nuget packages

* Updated namespace of Program.cs and Startup.cs and replace these with the project name in templates

* Bugfixes for sqlce

* Simplified template to have one template with --UseSqlCe as option

* Update build/build.ps1

Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>

Co-authored-by: Elitsa Marinovska <21998037+elit0451@users.noreply.github.com>
This commit is contained in:
Bjarke Berg
2020-08-11 08:28:16 +02:00
committed by GitHub
parent 94e1056dd9
commit 3c2f2ac0b3
10 changed files with 107 additions and 13 deletions

View File

@@ -24,21 +24,20 @@
not want this to happen as the alpha of the next major is, really, the next major already.
-->
<dependency id="UmbracoCms.Core" version="[$version$]" />
</group>
<group targetFramework="net472">
<dependency id="Umbraco.SqlServerCE" version="[4.0.0.1,4.999999)" />
<dependency id="Umbraco.SqlServerCE" version="[4.0.0.1,4.999999)" /> <!-- Hack it is only available in framework, but we need it on netstandard -->
</group>
</dependencies>
</metadata>
<files>
<!-- libs -->
<file src="$BuildTmp$\WebApp\bin\Umbraco.Persistance.SqlCe.dll" target="lib\net472\Umbraco.Persistance.SqlCe.dll" />
<file src="$BuildTmp$\WebApp\bin\Umbraco.Persistance.SqlCe.dll" target="lib\netstandard2.0\Umbraco.Persistance.SqlCe.dll" />
<file src="$BuildTmp$\WebApp\bin\System.Data.SqlServerCe.dll" target="lib\netstandard2.0\System.Data.SqlServerCe.dll" /> <!-- Hack because the file from the package is only added to net472 projects -->
<!-- docs -->
<file src="$BuildTmp$\WebApp\bin\Umbraco.Persistance.SqlCe.xml" target="lib\net472\Umbraco.Persistance.SqlCe.xml" />
<file src="$BuildTmp$\WebApp\bin\Umbraco.Persistance.SqlCe.xml" target="lib\netstandard2.0\Umbraco.Persistance.SqlCe.xml" />
<!-- symbols -->
<file src="$BuildTmp$\WebApp\bin\Umbraco.Persistance.SqlCe.pdb" target="lib\net472\Umbraco.Persistance.SqlCe.pdb" />
<file src="$BuildTmp$\WebApp\bin\Umbraco.Persistance.SqlCe.pdb" target="lib\netstandard2.0\Umbraco.Persistance.SqlCe.pdb" />
</files>
</package>

View File

@@ -30,10 +30,9 @@
<dependency id="MiniProfiler.AspNetCore.Mvc" version="[4.1.0,4.999999)" />
<dependency id="NETStandard.Library" version="[2.0.3,2.999999)" />
<dependency id="Serilog.AspNetCore" version="[3.2.0,3.999999)" />
<dependency id="SixLabors.ImageSharp.Web" version="[1.0.0-rc0001,1.999999)" />
<dependency id="Smidge" version="[3.1.0,3.999999)" />
<dependency id="Smidge" version="[3.1.1,3.999999)" />
<dependency id="Smidge.Nuglify" version="[2.0.0,2.999999)" />
<dependency id="SixLabors.ImageSharp.Web" version="[1.0.0-rc0001,1.999999)" />
<dependency id="SixLabors.ImageSharp.Web" version="[1.0.0-rc0003,1.999999)" />
</group>
</dependencies>

View File

@@ -183,7 +183,7 @@
$this.CopyFiles("$($this.SolutionRoot)\src\Umbraco.Web.UI.NetCore\Config", "*", "$($this.BuildTemp)\WebApp\config")
$this.RemoveFile("$($this.BuildTemp)\WebApp\Config\*.Release.*")
$this.CopyFiles("$($this.SolutionRoot)\src\Umbraco.Web.UI.NetCore\Umbraco", "*", "$($this.BuildTemp)\WebApp\umbraco")
$excludeUmbracoDirs = @("$($this.BuildTemp)\WebApp\umbraco\config","$($this.BuildTemp)\WebApp\umbraco\lib")
$excludeUmbracoDirs = @("$($this.BuildTemp)\WebApp\umbraco\lib")
$this.RemoveDirectory($excludeUmbracoDirs)
$this.CopyFiles("$($this.SolutionRoot)\src\Umbraco.Web.UI.NetCore\Views", "*", "$($this.BuildTemp)\WebApp\Views")
Copy-Item "$($this.SolutionRoot)\src\Umbraco.Web.UI.NetCore\appsettings.json" "$($this.BuildTemp)\WebApp"
@@ -262,6 +262,7 @@
$src = "$($this.SolutionRoot)\src"
$tmp = "$($this.BuildTemp)"
$out = "$($this.BuildOutput)"
$templates = "$($this.SolutionRoot)\build\templates"
$buildConfiguration = "Release"
@@ -282,6 +283,7 @@
mkdir "$tmp\Configs" > $null
mkdir "$tmp\Configs\Lang" > $null
mkdir "$tmp\WebApp\App_Data" > $null
mkdir "$tmp\Templates" > $null
#mkdir "$tmp\WebApp\Media" > $null
#mkdir "$tmp\WebApp\Views" > $null
@@ -326,10 +328,25 @@
$this.CopyFiles("$src\Umbraco.Web.UI.NetCore\wwwroot\umbraco\js", "*", "$tmp\WebApp\wwwroot\umbraco\js")
$this.CopyFiles("$src\Umbraco.Web.UI.NetCore\wwwroot\umbraco\lib", "*", "$tmp\WebApp\wwwroot\umbraco\lib")
$this.CopyFiles("$src\Umbraco.Web.UI.NetCore\wwwroot\umbraco\views", "*", "$tmp\WebApp\wwwroot\umbraco\views")
# Prepare templates
Write-Host "Copy template files"
$this.CopyFiles("$templates", "*", "$tmp\Templates")
Write-Host "Copy program.cs and startup.cs for templates"
$this.CopyFiles("$src\Umbraco.Web.UI.NetCore", "Program.cs", "$tmp\Templates\UmbracoSolution")
$this.CopyFiles("$src\Umbraco.Web.UI.NetCore", "Startup.cs", "$tmp\Templates\UmbracoSolution")
$this.CopyFiles("$src\Umbraco.Web.UI.NetCore", "appsettings.json", "$tmp\Templates\UmbracoSolution")
$this.CopyFiles("$src\Umbraco.Web.UI.NetCore", "appsettings.Development.json", "$tmp\Templates\UmbracoSolution")
$this.RemoveDirectory("$tmp\Templates\UmbracoSolution\bin")
})
$ubuild.DefineMethod("PackageZip",
{
Write-Host "Create Zip packages"
$src = "$($this.SolutionRoot)\src"
@@ -392,6 +409,7 @@
$ubuild.DefineMethod("PackageNuGet",
{
$nuspecs = "$($this.SolutionRoot)\build\NuSpecs"
$templates = "$($this.BuildTemp)\Templates"
Write-Host "Create NuGet packages"
@@ -419,6 +437,12 @@
-Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmssqlce.log"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.SqlCe." }
&$this.BuildEnv.NuGet Pack "$templates\Umbraco.Templates.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version "$($this.Version.Semver.ToString())" `
-Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.templates.log"
if (-not $?) { throw "Failed to pack NuGet Umbraco.Templates." }
# run hook
if ($this.HasMethod("PostPackageNuGet"))
{

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata minClientVersion="4.1.0">
<id>Umbraco.Templates</id>
<version>1.0.0</version>
<authors>Umbraco HQ</authors>
<owners>Umbraco HQ</owners>
<license type="expression">MIT</license>
<projectUrl>https://umbraco.com/</projectUrl>
<iconUrl>https://umbraco.com/dist/nuget/logo-small.png</iconUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Umbraco Cms templates for .NET Core Template Engine available through the dotnet CLI's new command</description>
<language>en-US</language>
<tags>umbraco</tags>
<repository type="git" url="https://github.com/umbraco/umbraco-cms" />
<packageTypes>
<packageType name="Template" />
</packageTypes>
</metadata>
</package>

View File

@@ -0,0 +1,38 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "Umbraco HQ",
"classifications": [ "Web", "CMS", "Umbraco"],
"identity": "Umbraco.Templates",
"name": "Umbraco - Empty Solution",
"shortName": "umbraco",
"tags": {
"language": "C#",
"type": "project"
},
"sourceName": "UmbracoSolution", // Will be replaced with the value provided via -n
"preferNameDirectory": true,
"symbols": {
"version": {
"type": "parameter",
"datatype": "string",
"defaultValue": "9.0.0",
"description": "The version of Umbraco to load using NuGet",
"replaces": "UMBRACO_VERSION_FROM_TEMPLATE"
},
"namespaceReplacer": {
"type": "generated",
"generator": "coalesce",
"parameters": {
"sourceVariableName": "name",
"defaultValue": "UmbracoSolution",
"fallbackVariableName": "name"
},
"replaces":"Umbraco.Web.UI.NetCore"
},
"UseSqlCe":{
"type": "parameter",
"datatype":"bool",
"defaultValue": "false"
}
}
}

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="UmbracoCms" Version="UMBRACO_VERSION_FROM_TEMPLATE" />
<PackageReference Include="UmbracoCms.SqlCe" Version="UMBRACO_VERSION_FROM_TEMPLATE" Condition="'$(UseSqlCe)' == 'true'" />
<PackageReference Include="Umbraco.SqlServerCE" Version="4.0.0.1" Condition="'$(UseSqlCe)' == 'true'" />
</ItemGroup>
</Project>

View File

@@ -20,7 +20,7 @@ using Umbraco.Core.Mapping;
using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
using Umbraco.Web.Common.Security;
using Umbraco.Web.UI.BackOffice;
using Umbraco.Web.UI.NetCore;
namespace Umbraco.Tests.Integration.TestServerTest
{

View File

@@ -2,7 +2,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Umbraco.Core.Composing;
namespace Umbraco.Web.UI.BackOffice
namespace Umbraco.Web.UI.NetCore
{
public class Program
{

View File

@@ -7,7 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Umbraco.Extensions;
namespace Umbraco.Web.UI.BackOffice
namespace Umbraco.Web.UI.NetCore
{
public class Startup
{

View File

@@ -34,6 +34,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuSpecs", "NuSpecs", "{227C
..\build\NuSpecs\UmbracoCms.Core.nuspec = ..\build\NuSpecs\UmbracoCms.Core.nuspec
..\build\NuSpecs\UmbracoCms.nuspec = ..\build\NuSpecs\UmbracoCms.nuspec
..\build\NuSpecs\UmbracoCms.Web.nuspec = ..\build\NuSpecs\UmbracoCms.Web.nuspec
..\build\NuSpecs\UmbracoCms.SqlCe.nuspec = ..\build\NuSpecs\UmbracoCms.SqlCe.nuspec
EndProjectSection
EndProject
Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "Umbraco.Web.UI.Client", "http://localhost:3961", "{3819A550-DCEC-4153-91B4-8BA9F7F0B9B4}"