diff --git a/eng/scripts/InstallJdk.ps1 b/eng/scripts/InstallJdk.ps1 index ba76964e17..e56e768f4f 100644 --- a/eng/scripts/InstallJdk.ps1 +++ b/eng/scripts/InstallJdk.ps1 @@ -2,7 +2,7 @@ param( [Parameter(Mandatory = $true)] $JdkVersion - ) +) $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138 diff --git a/eng/targets/ResolveReferences.targets b/eng/targets/ResolveReferences.targets index f67d97dce2..3eeface237 100644 --- a/eng/targets/ResolveReferences.targets +++ b/eng/targets/ResolveReferences.targets @@ -204,7 +204,7 @@ - diff --git a/src/ProjectTemplates/README.md b/src/ProjectTemplates/README.md index ae1f73d94d..df43602b76 100644 --- a/src/ProjectTemplates/README.md +++ b/src/ProjectTemplates/README.md @@ -4,7 +4,9 @@ These are project templates which are used in .NET Core for creating ASP.NET Core applications. ## Building Templates -- Run `build.cmd -Pack` in the repository root to build all of the dependencies. -- Run `build.cmd` in this directory will produce NuGet packages for each class of template in the artifacts directory. These can be installed via `dotnet new -i {nugetpackage path}` -- The ASP.NET localhost development certificate must also be installed and trusted or else you'll get a test error "Certificate error: Navigation blocked". -- You also need to get the packages these templates depend on into your package cache or else `dotnet new` restore will fail. The easiest way to get them to run is by letting the build run at least 1 test. Note currently some packages are missed. https://github.com/aspnet/AspNetCore/issues/7388 \ No newline at end of file +1. Run `. .\activate.ps1` if you haven't already. + +2. Run `build.cmd -all -pack` in the repository root to build all of the dependencies. +3. Run `build.cmd` in this directory will produce NuGet packages for each class of template in the artifacts directory. +4. Because the templates build against the version of `Microsoft.AspNetCore.App` that was built during step 2 it is NOT advised that you install templates created on your local machine via `dotnet new -i [nupkgPath]`. Instead, use the `Run-[Template]-Locally.ps1` scripts in the script folder. These scripts do `dotnet new -i` with your packages, but also apply a series of fixes and tweeks to the created template which keep the fact that you don't have a production `Microsoft.AspNetCore.App` from interfering. +5. The ASP.NET localhost development certificate must also be installed and trusted or else you'll get a test error "Certificate error: Navigation blocked". diff --git a/src/ProjectTemplates/scripts/Directory.Build.props b/src/ProjectTemplates/scripts/Directory.Build.props new file mode 100644 index 0000000000..8998bf4546 --- /dev/null +++ b/src/ProjectTemplates/scripts/Directory.Build.props @@ -0,0 +1 @@ + diff --git a/src/ProjectTemplates/scripts/Directory.Build.targets b/src/ProjectTemplates/scripts/Directory.Build.targets new file mode 100644 index 0000000000..8998bf4546 --- /dev/null +++ b/src/ProjectTemplates/scripts/Directory.Build.targets @@ -0,0 +1 @@ + diff --git a/src/ProjectTemplates/scripts/Run-Angular-Locally.ps1 b/src/ProjectTemplates/scripts/Run-Angular-Locally.ps1 index b764ef88ad..d2f2a92bce 100644 --- a/src/ProjectTemplates/scripts/Run-Angular-Locally.ps1 +++ b/src/ProjectTemplates/scripts/Run-Angular-Locally.ps1 @@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop' . $PSScriptRoot\Test-Template.ps1 -Test-Template "angular" "angular" "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-preview-t000.nupkg" $true +Test-Template "angular" "angular" "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-preview4-t000.nupkg" $true diff --git a/src/ProjectTemplates/scripts/Run-EmptyWeb-Locally.ps1 b/src/ProjectTemplates/scripts/Run-EmptyWeb-Locally.ps1 index a0125f658a..fc06d65294 100644 --- a/src/ProjectTemplates/scripts/Run-EmptyWeb-Locally.ps1 +++ b/src/ProjectTemplates/scripts/Run-EmptyWeb-Locally.ps1 @@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop' . $PSScriptRoot\Test-Template.ps1 -Test-Template "web" "web" "Microsoft.DotNet.Web.ProjectTemplates.3.0.3.0.0-preview-t000.nupkg" $false +Test-Template "web" "web" "Microsoft.DotNet.Web.ProjectTemplates.3.0.3.0.0-preview4-t000.nupkg" $false diff --git a/src/ProjectTemplates/scripts/Run-React-Locally.ps1 b/src/ProjectTemplates/scripts/Run-React-Locally.ps1 index 8707df6796..0be4d48aab 100644 --- a/src/ProjectTemplates/scripts/Run-React-Locally.ps1 +++ b/src/ProjectTemplates/scripts/Run-React-Locally.ps1 @@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop' . $PSScriptRoot\Test-Template.ps1 -Test-Template "react" "react" "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-alpha1.nupkg" $true +Test-Template "react" "react" "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-preview4-t000.nupkg" $true diff --git a/src/ProjectTemplates/scripts/Run-ReactRedux-Locally.ps1 b/src/ProjectTemplates/scripts/Run-ReactRedux-Locally.ps1 index be39c16a59..5bec0dccc5 100644 --- a/src/ProjectTemplates/scripts/Run-ReactRedux-Locally.ps1 +++ b/src/ProjectTemplates/scripts/Run-ReactRedux-Locally.ps1 @@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop' . $PSScriptRoot\Test-Template.ps1 -Test-Template "reactredux" "reactredux" "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-alpha1.nupkg" $true +Test-Template "reactredux" "reactredux" "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-preview4-t000.nupkg" $true diff --git a/src/ProjectTemplates/scripts/Run-Starterweb-Locally.ps1 b/src/ProjectTemplates/scripts/Run-Starterweb-Locally.ps1 index a309da7e8a..f2e095a3f5 100644 --- a/src/ProjectTemplates/scripts/Run-Starterweb-Locally.ps1 +++ b/src/ProjectTemplates/scripts/Run-Starterweb-Locally.ps1 @@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop' . $PSScriptRoot\Test-Template.ps1 -Test-Template "mvc" "mvc -au Individual" "Microsoft.DotNet.Web.ProjectTemplates.3.0.3.0.0-preview-t000.nupkg" $false +Test-Template "mvc" "mvc -au Individual" "Microsoft.DotNet.Web.ProjectTemplates.3.0.3.0.0-preview4-t000.nupkg" $false diff --git a/src/ProjectTemplates/scripts/Test-Template.ps1 b/src/ProjectTemplates/scripts/Test-Template.ps1 index cb619ead35..62ee71539b 100644 --- a/src/ProjectTemplates/scripts/Test-Template.ps1 +++ b/src/ProjectTemplates/scripts/Test-Template.ps1 @@ -1,3 +1,9 @@ +#!/usr/bin/env pwsh +#requires -version 4 + +Set-StrictMode -Version 2 +$ErrorActionPreference = 'Stop' + function Test-Template($templateName, $templateArgs, $templateNupkg, $isSPA) { $tmpDir = "$PSScriptRoot/$templateName" Remove-Item -Path $tmpDir -Recurse -ErrorAction Ignore @@ -23,7 +29,10 @@ function Test-Template($templateName, $templateArgs, $templateNupkg, $isSPA) { - ") + + + true + ") $projContent | Set-Content $proj dotnet ef migrations add mvc dotnet publish --configuration Release diff --git a/src/ProjectTemplates/test/Helpers/AspNetProcess.cs b/src/ProjectTemplates/test/Helpers/AspNetProcess.cs index 4fa3d54450..b00ec602be 100644 --- a/src/ProjectTemplates/test/Helpers/AspNetProcess.cs +++ b/src/ProjectTemplates/test/Helpers/AspNetProcess.cs @@ -29,7 +29,7 @@ namespace Templates.Test.Helpers ITestOutputHelper output, string workingDirectory, string dllPath, - IDictionary environmentVariables) + IDictionary environmentVariables) { _output = output; _httpClient = new HttpClient(new HttpClientHandler() diff --git a/src/ProjectTemplates/test/SpaTemplateTest/ReactReduxTemplateTest.cs b/src/ProjectTemplates/test/SpaTemplateTest/ReactReduxTemplateTest.cs index c1724754c3..44d6b67f32 100644 --- a/src/ProjectTemplates/test/SpaTemplateTest/ReactReduxTemplateTest.cs +++ b/src/ProjectTemplates/test/SpaTemplateTest/ReactReduxTemplateTest.cs @@ -18,6 +18,6 @@ namespace Templates.Test.SpaTemplateTest [Fact] public Task ReactReduxTemplate_Works_NetCore() - => SpaTemplateImplAsync("reactredux", "reactredux",useLocalDb: false, usesAuth: false); + => SpaTemplateImplAsync("reactredux", "reactredux", useLocalDb: false, usesAuth: false); } }