Improve local development of Templates (#8196)
This commit is contained in:
parent
f5ff181222
commit
0c4b3fbd6d
|
|
@ -2,7 +2,7 @@
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
$JdkVersion
|
$JdkVersion
|
||||||
)
|
)
|
||||||
|
|
||||||
$ErrorActionPreference = 'Stop'
|
$ErrorActionPreference = 'Stop'
|
||||||
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
|
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
|
||||||
|
|
|
||||||
|
|
@ -204,7 +204,7 @@
|
||||||
<Warning Condition="@(UnusedBaselinePackageReference->Count()) != 0"
|
<Warning Condition="@(UnusedBaselinePackageReference->Count()) != 0"
|
||||||
Text="Package references changed since the last release. This could be a breaking change. References removed:%0A - @(UnusedBaselinePackageReference, '%0A -')" />
|
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"
|
Code="MSB3245"
|
||||||
Text="Could not resolve this reference. Could not locate the package or project for "%(Reference.Identity)". Did you update baselines and dependencies lists? See docs/ReferenceResolution.md for more details." />
|
Text="Could not resolve this reference. Could not locate the package or project for "%(Reference.Identity)". Did you update baselines and dependencies lists? See docs/ReferenceResolution.md for more details." />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,9 @@
|
||||||
These are project templates which are used in .NET Core for creating ASP.NET Core applications.
|
These are project templates which are used in .NET Core for creating ASP.NET Core applications.
|
||||||
|
|
||||||
## Building Templates
|
## Building Templates
|
||||||
- Run `build.cmd -Pack` in the repository root to build all of the dependencies.
|
1. Run `. .\activate.ps1` if you haven't already.
|
||||||
- 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".
|
2. Run `build.cmd -all -pack` in the repository root to build all of the dependencies.
|
||||||
- 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
|
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".
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<Project/>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
<Project/>
|
||||||
|
|
@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
. $PSScriptRoot\Test-Template.ps1
|
. $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
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
. $PSScriptRoot\Test-Template.ps1
|
. $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
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
. $PSScriptRoot\Test-Template.ps1
|
. $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
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
. $PSScriptRoot\Test-Template.ps1
|
. $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
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
. $PSScriptRoot\Test-Template.ps1
|
. $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
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,9 @@
|
||||||
|
#!/usr/bin/env pwsh
|
||||||
|
#requires -version 4
|
||||||
|
|
||||||
|
Set-StrictMode -Version 2
|
||||||
|
$ErrorActionPreference = 'Stop'
|
||||||
|
|
||||||
function Test-Template($templateName, $templateArgs, $templateNupkg, $isSPA) {
|
function Test-Template($templateName, $templateArgs, $templateNupkg, $isSPA) {
|
||||||
$tmpDir = "$PSScriptRoot/$templateName"
|
$tmpDir = "$PSScriptRoot/$templateName"
|
||||||
Remove-Item -Path $tmpDir -Recurse -ErrorAction Ignore
|
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"" />
|
<Import Project=""$PSScriptRoot/../test/bin/Debug/netcoreapp3.0/TemplateTests.props"" />
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include=""Microsoft.NET.Sdk.Razor"" Version=""`$(MicrosoftNETSdkRazorPackageVersion)"" />
|
<PackageReference Include=""Microsoft.NET.Sdk.Razor"" Version=""`$(MicrosoftNETSdkRazorPackageVersion)"" />
|
||||||
</ItemGroup>")
|
</ItemGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<DisablePackageReferenceRestrictions>true</DisablePackageReferenceRestrictions>
|
||||||
|
</PropertyGroup>")
|
||||||
$projContent | Set-Content $proj
|
$projContent | Set-Content $proj
|
||||||
dotnet ef migrations add mvc
|
dotnet ef migrations add mvc
|
||||||
dotnet publish --configuration Release
|
dotnet publish --configuration Release
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Templates.Test.Helpers
|
||||||
ITestOutputHelper output,
|
ITestOutputHelper output,
|
||||||
string workingDirectory,
|
string workingDirectory,
|
||||||
string dllPath,
|
string dllPath,
|
||||||
IDictionary<string,string> environmentVariables)
|
IDictionary<string, string> environmentVariables)
|
||||||
{
|
{
|
||||||
_output = output;
|
_output = output;
|
||||||
_httpClient = new HttpClient(new HttpClientHandler()
|
_httpClient = new HttpClient(new HttpClientHandler()
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,6 @@ namespace Templates.Test.SpaTemplateTest
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public Task ReactReduxTemplate_Works_NetCore()
|
public Task ReactReduxTemplate_Works_NetCore()
|
||||||
=> SpaTemplateImplAsync("reactredux", "reactredux",useLocalDb: false, usesAuth: false);
|
=> SpaTemplateImplAsync("reactredux", "reactredux", useLocalDb: false, usesAuth: false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue