Improve local development of Templates (#8196)

This commit is contained in:
Ryan Brandenburg 2019-03-21 16:29:45 -07:00 committed by GitHub
parent f5ff181222
commit 0c4b3fbd6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 27 additions and 14 deletions

View File

@ -2,7 +2,7 @@
param(
[Parameter(Mandatory = $true)]
$JdkVersion
)
)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138

View File

@ -204,7 +204,7 @@
<Warning Condition="@(UnusedBaselinePackageReference->Count()) != 0"
Text="Package references changed since the last release. This could be a breaking change. References removed:%0A - @(UnusedBaselinePackageReference, '%0A -')" />
<Error Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework' AND '%(Reference.Identity)' != '' AND ! Exists('%(Reference.Identity)')"
<Error Condition="'$(TargetFrameworkIdentifier)' != '.NETFramework' AND '%(Reference.Identity)' != '' AND ! Exists('%(Reference.Identity)') AND '$(DisablePackageReferenceRestrictions)' != 'true'"
Code="MSB3245"
Text="Could not resolve this reference. Could not locate the package or project for &quot;%(Reference.Identity)&quot;. Did you update baselines and dependencies lists? See docs/ReferenceResolution.md for more details." />
</Target>

View File

@ -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
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".

View File

@ -0,0 +1 @@
<Project/>

View File

@ -0,0 +1 @@
<Project/>

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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) {
<Import Project=""$PSScriptRoot/../test/bin/Debug/netcoreapp3.0/TemplateTests.props"" />
<ItemGroup>
<PackageReference Include=""Microsoft.NET.Sdk.Razor"" Version=""`$(MicrosoftNETSdkRazorPackageVersion)"" />
</ItemGroup>")
</ItemGroup>
<PropertyGroup>
<DisablePackageReferenceRestrictions>true</DisablePackageReferenceRestrictions>
</PropertyGroup>")
$projContent | Set-Content $proj
dotnet ef migrations add mvc
dotnet publish --configuration Release

View File

@ -29,7 +29,7 @@ namespace Templates.Test.Helpers
ITestOutputHelper output,
string workingDirectory,
string dllPath,
IDictionary<string,string> environmentVariables)
IDictionary<string, string> environmentVariables)
{
_output = output;
_httpClient = new HttpClient(new HttpClientHandler()

View File

@ -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);
}
}