Fix Templates

This commit is contained in:
Ryan Brandenburg 2019-01-17 14:18:22 -08:00 committed by Artak
parent 82701c1eba
commit 10b63c06db
23 changed files with 138 additions and 24 deletions

View File

@ -4,7 +4,7 @@
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<MicrosoftAspNetCoreAppPackageVersion>3.0.0-preview-19065-0365</MicrosoftAspNetCoreAppPackageVersion>
<MicrosoftAspNetCoreAppPackageVersion>3.0.0-preview-19066-0374</MicrosoftAspNetCoreAppPackageVersion>
<MicrosoftAspNetCoreAuthenticationAzureADB2CUIPackageVersion>3.0.0-preview-19059-0307 </MicrosoftAspNetCoreAuthenticationAzureADB2CUIPackageVersion>
<MicrosoftAspNetCoreAuthenticationAzureADUIPackageVersion>3.0.0-preview-19059-0307 </MicrosoftAspNetCoreAuthenticationAzureADUIPackageVersion>
<MicrosoftAspNetCoreComponentsPackageVersion>3.0.0-preview-19064-0342</MicrosoftAspNetCoreComponentsPackageVersion>

View File

@ -9,4 +9,4 @@ $ErrorActionPreference = 'Stop'
. $PSScriptRoot\Test-Template.ps1
Test-Template "angular" "angular" "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-alpha1.nupkg" $true
Test-Template "angular" "angular" "Microsoft.DotNet.Web.Spa.ProjectTemplates.3.0.0-preview-t000.nupkg" $true

View File

@ -0,0 +1,12 @@
#!/usr/bin/env pwsh
#requires -version 4
[CmdletBinding(PositionalBinding = $false)]
param()
Set-StrictMode -Version 2
$ErrorActionPreference = 'Stop'
. $PSScriptRoot\Test-Template.ps1
Test-Template "web" "web" "Microsoft.DotNet.Web.ProjectTemplates.3.0.3.0.0-preview-t000.nupkg" $false

View File

@ -1,6 +1,7 @@
function Test-Template($templateName, $templateArgs, $templateNupkg, $isSPA) {
$tmpDir = "$PSScriptRoot/$templateName"
Remove-Item -Path $tmpDir -Recurse -ErrorAction Ignore
dotnet pack
Run-DotnetNew "--install", "$PSScriptRoot/../../../artifacts/Debug/packages/product/$templateNupkg"
@ -24,7 +25,7 @@ function Test-Template($templateName, $templateArgs, $templateNupkg, $isSPA) {
<PackageReference Include=""Microsoft.NET.Sdk.Razor"" Version=""`$(MicrosoftNETSdkRazorPackageVersion)"" />
</ItemGroup>")
$projContent | Set-Content $proj
dotnet ef migrations add mvc
dotnet publish --configuration Release
dotnet bin\Release\netcoreapp3.0\publish\$templateName.dll
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace web
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
namespace web
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting(routes =>
{
routes.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="D:\dd\AspNetCore\src\Templating\scripts/../test/Templates.Test/bin/Debug/netcoreapp3.0/TemplateTests.props" />
<!-- <ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Razor" Version="$(MicrosoftNETSdkRazorPackageVersion)" />
</ItemGroup> -->
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>

View File

@ -5,8 +5,4 @@
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.RazorClassLibrary1</RootNamespace>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>

View File

@ -26,7 +26,6 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="${MicrosoftEntityFrameworkCoreSqlServerPackageVersion}" Condition=" '$(IndividualLocalAuth)' == 'True' AND '$(UseLocalDB)' == 'True'" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="${MicrosoftEntityFrameworkCoreSqlitePackageVersion}" Condition=" '$(IndividualLocalAuth)' == 'True' AND '$(UseLocalDB)' != 'True'" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="${MicrosoftEntityFrameworkCoreToolsPackageVersion}" Condition=" '$(IndividualLocalAuth)' == 'True' " />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="3.0.0-preview-181109-02" />
</ItemGroup>
</Project>

View File

@ -15,6 +15,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="${MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" />
</ItemGroup>

View File

@ -23,6 +23,7 @@
<GeneratedContentProperties>
MicrosoftAspNetCorePackageVersion=$(MicrosoftAspNetCorePackageVersion);
MicrosoftAspNetCoreAppPackageVersion=$(MicrosoftAspNetCoreAppPackageVersion);
MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion=$(MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion);
MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion=$(MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion);
</GeneratedContentProperties>
</PropertyGroup>

View File

@ -12,6 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="${MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" />
</ItemGroup>

View File

@ -12,6 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="${MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion}" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="${MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion}" />
</ItemGroup>

View File

@ -22,7 +22,8 @@ namespace Company.WebApplication1
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc()
.AddNewtonsoftJson(); ;
// In production, the Angular files will be served from this directory
services.AddSpaStaticFiles(configuration =>

View File

@ -22,7 +22,8 @@ namespace Company.WebApplication1
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc()
.AddNewtonsoftJson();
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>

View File

@ -22,7 +22,8 @@ namespace Company.WebApplication1
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc()
.AddNewtonsoftJson();
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>

View File

@ -4,6 +4,7 @@
<RestoreSources>${RestoreSources}</RestoreSources>
<RuntimeFrameworkVersion>${RuntimeFrameworkVersion}</RuntimeFrameworkVersion>
<MicrosoftNETSdkRazorPackageVersion>${MicrosoftNETSdkRazorPackageVersion}</MicrosoftNETSdkRazorPackageVersion>
<AspNetCoreModuleName>AspNetCoreModuleV2</AspNetCoreModuleName>
</PropertyGroup>
<ItemGroup>
@ -13,4 +14,8 @@
LatestRuntimeFrameworkVersion="${MicrosoftAspNetCoreAppPackageVersion}"
TargetingPackVersion="${MicrosoftAspNetCoreAppPackageVersion}" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netstandard2.0'" >
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>

View File

@ -13,6 +13,7 @@ using System.Linq;
using System.Net.Http;
using System.Security.Cryptography;
using System.Threading.Tasks;
using Templates.Test.Helpers;
using Xunit;
using Xunit.Abstractions;
@ -22,16 +23,12 @@ namespace Templates.Test
{
private readonly ITestOutputHelper _output;
private readonly HttpClient _httpClient;
private static readonly string _solutionDir;
private static readonly string _artifactsDir;
private static List<ScriptTag> _scriptTags;
private static List<LinkTag> _linkTags;
static CdnScriptTagTests()
{
_solutionDir = GetSolutionDir();
_artifactsDir = Path.Combine(_solutionDir, "artifacts", "build");
var packages = Directory.GetFiles(_artifactsDir, "*.nupkg");
var packages = MondoHelpers.GetNupkgFiles();
_scriptTags = new List<ScriptTag>();
_linkTags = new List<LinkTag>();
@ -164,7 +161,7 @@ namespace Templates.Test
private static string GetFileContentFromArchive(ScriptTag scriptTag, string relativeFilePath)
{
var file = Path.Combine(_artifactsDir, scriptTag.FileName);
var file = MondoHelpers.GetNupkgFiles().Single(f => f.EndsWith(scriptTag.FileName));
using (var zip = new ZipArchive(File.OpenRead(file), ZipArchiveMode.Read, leaveOpen: false))
{
var entry = zip.Entries

View File

@ -119,8 +119,9 @@ namespace Templates.Test.Helpers
var listeningMessage = _process
.OutputLinesAsEnumerable
.Where(line => line != null)
.FirstOrDefault(line => line.StartsWith(ListeningMessagePrefix, StringComparison.Ordinal));
.FirstOrDefault(line => line.Trim().StartsWith(ListeningMessagePrefix, StringComparison.Ordinal));
Assert.True(!string.IsNullOrEmpty(listeningMessage), $"ASP.NET process exited without listening for requests.\nOutput: { _process.Output }\nError: { _process.Error }");
listeningMessage = listeningMessage.Trim();
// Verify we have a valid URL to make requests to
var listeningUrlString = listeningMessage.Substring(ListeningMessagePrefix.Length);

View File

@ -56,11 +56,6 @@ $@"<Project>
var directoryBuildTargetsContent =
$@"<Project>
<Import Project=""{templatesTestsPropsFilePath}"" />
<ItemGroup>
<FrameworkReference Remove=""Microsoft.AspNetCore.App"" />
<PackageReference Include=""Microsoft.AspNetCore.App"" Version=""$(BundledAspNetCoreAppPackageVersion)"" IsImplicitlyDefined=""true"" />
</ItemGroup>
</Project>";
File.WriteAllText(Path.Combine(TemplateOutputDir, "Directory.Build.targets"), directoryBuildTargetsContent);

View File

@ -29,7 +29,10 @@ namespace Templates.Test
"<Project />");
File.WriteAllText(
Path.Combine(TemplateOutputDir, "Directory.Build.targets"),
"<Project />");
@"<Project> <ItemGroup Condition=""'$(TargetFramework)' != 'netstandard2.0'"" >
<FrameworkReference Include = ""Microsoft.AspNetCore.App"" />
</ItemGroup>
</Project>");
// Run the "server" project
ProjectName += ".Server";