Fix Templating

This commit is contained in:
Ryan Brandenburg 2019-01-16 10:54:07 -08:00 committed by Artak
parent cca71ad4d2
commit 82701c1eba
8 changed files with 72 additions and 57 deletions

View File

@ -1,36 +1,20 @@
<Project>
<Import Project="../../../eng/Versions.props" />
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup Label="Package Versions">
<AngleSharpPackageVersion>0.9.9</AngleSharpPackageVersion>
<DotNetEfPackageVersion>3.0.0-preview-181109-02</DotNetEfPackageVersion>
<InternalAspNetCoreSdkPackageVersion>3.0.0-alpha1-20181017.4</InternalAspNetCoreSdkPackageVersion>
<MicrosoftAspNetCoreAppPackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCoreAppPackageVersion>
<MicrosoftAspNetCoreAuthenticationAzureADB2CUIPackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCoreAuthenticationAzureADB2CUIPackageVersion>
<MicrosoftAspNetCoreAuthenticationAzureADUIPackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCoreAuthenticationAzureADUIPackageVersion>
<MicrosoftAspNetCoreAppPackageVersion>3.0.0-preview-19065-0365</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>
<MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreIdentityUIPackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCoreIdentityUIPackageVersion>
<MicrosoftAspNetCorePackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCorePackageVersion>
<MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion>
<MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion>3.0.0-alpha1-10742</MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion>
<MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>3.0.0-preview-19059-0307 </MicrosoftAspNetCoreDiagnosticsEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>3.0.0-preview-19059-0307 </MicrosoftAspNetCoreIdentityEntityFrameworkCorePackageVersion>
<MicrosoftAspNetCoreIdentityUIPackageVersion>3.0.0-preview-19059-0307 </MicrosoftAspNetCoreIdentityUIPackageVersion>
<MicrosoftAspNetCorePackageVersion>3.0.0-preview-19059-0307 </MicrosoftAspNetCorePackageVersion>
<MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion>3.0.0-preview-19059-0307 </MicrosoftAspNetCoreMvcNewtonsoftJsonPackageVersion>
<MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion>3.0.0-preview-19059-0307 </MicrosoftAspNetCoreSpaServicesExtensionsPackageVersion>
<MicrosoftAspNetCoreTestingPackageVersion>3.0.0-preview-181113-11</MicrosoftAspNetCoreTestingPackageVersion>
<MicrosoftEntityFrameworkCoreSqlitePackageVersion>3.0.0-preview-181109-02</MicrosoftEntityFrameworkCoreSqlitePackageVersion>
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>3.0.0-preview-181109-02</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
<MicrosoftEntityFrameworkCoreToolsPackageVersion>3.0.0-preview-181109-02</MicrosoftEntityFrameworkCoreToolsPackageVersion>
<MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>3.0.0-preview-181113-11</MicrosoftExtensionsCommandLineUtilsSourcesPackageVersion>
<MicrosoftNETCoreAppPackageVersion>3.0.0-preview1-26907-05</MicrosoftNETCoreAppPackageVersion>
<MicrosoftNETSdkRazorPackageVersion>3.0.0-preview-19057-06</MicrosoftNETSdkRazorPackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
<SeleniumSupportPackageVersion>3.12.1</SeleniumSupportPackageVersion>
<SeleniumWebDriverMicrosoftDriverPackageVersion>17.17134.0</SeleniumWebDriverMicrosoftDriverPackageVersion>
<SeleniumWebDriverPackageVersion>3.12.1</SeleniumWebDriverPackageVersion>
<SystemSecurityPermissionsPackageVersion>4.6.0-preview1-26907-04</SystemSecurityPermissionsPackageVersion>
<XunitAnalyzersPackageVersion>0.10.0</XunitAnalyzersPackageVersion>
<XunitPackageVersion>2.3.1</XunitPackageVersion>
<XunitRunnerVisualStudioPackageVersion>2.4.0</XunitRunnerVisualStudioPackageVersion>
</PropertyGroup>
<Import Project="$(DotNetPackageVersionPropsPath)" Condition=" '$(DotNetPackageVersionPropsPath)' != '' " />
<PropertyGroup Label="Package Versions: Pinned" />

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-alpha1.nupkg" $false
Test-Template "mvc" "mvc -au Individual" "Microsoft.DotNet.Web.ProjectTemplates.3.0.3.0.0-preview-t000.nupkg" $false

View File

@ -2,8 +2,7 @@ function Test-Template($templateName, $templateArgs, $templateNupkg, $isSPA) {
$tmpDir = "$PSScriptRoot/$templateName"
Remove-Item -Path $tmpDir -Recurse -ErrorAction Ignore
& "$PSScriptRoot/../build.cmd" /t:Package
Run-DotnetNew "--install", "$PSScriptRoot/../artifacts/build/$templateNupkg"
Run-DotnetNew "--install", "$PSScriptRoot/../../../artifacts/Debug/packages/product/$templateNupkg"
New-Item -ErrorAction Ignore -Path $tmpDir -ItemType Directory
Push-Location $tmpDir
@ -20,14 +19,14 @@ function Test-Template($templateName, $templateArgs, $templateNupkg, $isSPA) {
$proj = "$tmpDir/$templateName.$extension"
$projContent = Get-Content -Path $proj -Raw
$projContent = $projContent -replace ('<Project Sdk="Microsoft.NET.Sdk.Web">', "<Project Sdk=""Microsoft.NET.Sdk.Web"">
<Import Project=""$PSScriptRoot/../test/Templates.Test/bin/Debug/netcoreapp2.2/TemplateTests.props"" />
<Import Project=""$PSScriptRoot/../test/Templates.Test/bin/Debug/netcoreapp3.0/TemplateTests.props"" />
<ItemGroup>
<PackageReference Include=""Microsoft.NET.Sdk.Razor"" Version=""`$(MicrosoftNETSdkRazorPackageVersion)"" />
</ItemGroup>")
$projContent | Set-Content $proj
dotnet publish --configuration Release
dotnet bin\Release\netcoreapp2.2\publish\$templateName.dll
dotnet bin\Release\netcoreapp3.0\publish\$templateName.dll
}
finally {
Pop-Location

View File

@ -26,6 +26,7 @@
<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

@ -1,12 +1,12 @@
<Project>
<Target Name="GenerateTestProps" BeforeTargets="CoreCompile">
<Message Text="$(MicrosoftAspNetCoreAppPackageVersion)" Importance="High" />
<PropertyGroup>
<PropsProperties>
RestoreSources=$([MSBuild]::Escape($(RestoreSources)));
RuntimeFrameworkVersion=$(RuntimeFrameworkVersion);
MicrosoftNETSdkRazorPackageVersion=$(MicrosoftNETSdkRazorPackageVersion);
BundledAspNetCoreAppTargetFrameworkVersion=$(MicrosoftAspNetCoreAppPackageVersion.Split('.')[0]).$(MicrosoftAspNetCoreAppPackageVersion.Split('.')[1]);
BundledAspNetCoreAppPackageVersion=$(MicrosoftAspNetCoreAppPackageVersion)
MicrosoftAspNetCoreAppPackageVersion=$(MicrosoftAspNetCoreAppPackageVersion)
</PropsProperties>
</PropertyGroup>

View File

@ -4,7 +4,13 @@
<RestoreSources>${RestoreSources}</RestoreSources>
<RuntimeFrameworkVersion>${RuntimeFrameworkVersion}</RuntimeFrameworkVersion>
<MicrosoftNETSdkRazorPackageVersion>${MicrosoftNETSdkRazorPackageVersion}</MicrosoftNETSdkRazorPackageVersion>
<BundledAspNetCoreAppTargetFrameworkVersion>${BundledAspNetCoreAppTargetFrameworkVersion}</BundledAspNetCoreAppTargetFrameworkVersion>
<BundledAspNetCoreAppPackageVersion>${BundledAspNetCoreAppPackageVersion}</BundledAspNetCoreAppPackageVersion>
</PropertyGroup>
<ItemGroup>
<KnownFrameworkReference
Update="Microsoft.AspNetCore.App"
DefaultRuntimeFrameworkVersion="${MicrosoftAspNetCoreAppPackageVersion}"
LatestRuntimeFrameworkVersion="${MicrosoftAspNetCoreAppPackageVersion}"
TargetingPackVersion="${MicrosoftAspNetCoreAppPackageVersion}" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,44 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.IO;
namespace Templates.Test.Helpers
{
public static class MondoHelpers
{
public static string[] GetNupkgFiles()
{
var mondoRoot = GetMondoRepoRoot();
#if DEBUG
var configuration = "Debug";
#else
var configuration = "Release";
#endif
return Directory.GetFiles(Path.Combine(mondoRoot, "artifacts", configuration, "packages"), "*.nupkg", SearchOption.AllDirectories);
}
private static string GetMondoRepoRoot()
{
return FindAncestorDirectoryContaining(".gitmodules");
}
private static string FindAncestorDirectoryContaining(string filename)
{
var dir = AppContext.BaseDirectory;
while (dir != null)
{
if (File.Exists(Path.Combine(dir, filename)))
{
return dir;
}
dir = Directory.GetParent(dir)?.FullName;
}
throw new InvalidOperationException($"Could not find any ancestor directory containing {filename} at or above {AppContext.BaseDirectory}");
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
@ -70,7 +70,7 @@ namespace Templates.Test.Helpers
public static ProcessEx RunDotNetNew(ITestOutputHelper output, string arguments, bool assertSuccess)
{
lock(DotNetNewLock)
lock (DotNetNewLock)
{
var proc = ProcessEx.Run(
output,
@ -100,10 +100,7 @@ namespace Templates.Test.Helpers
VerifyCannotFindTemplate(output, "reactredux");
VerifyCannotFindTemplate(output, "angular");
// Locate the artifacts directory containing the built template packages
var solutionDir = FindAncestorDirectoryContaining("Templating.sln");
var artifactsDir = Path.Combine(solutionDir, "artifacts", "build");
var builtPackages = Directory.GetFiles(artifactsDir, "*.nupkg");
var builtPackages = MondoHelpers.GetNupkgFiles();
foreach (var packagePath in builtPackages)
{
if (_templatePackages.Any(name => Path.GetFileName(packagePath).StartsWith(name, StringComparison.OrdinalIgnoreCase)))
@ -146,21 +143,5 @@ namespace Templates.Test.Helpers
Directory.Delete(tempDir, recursive: true);
}
}
private static string FindAncestorDirectoryContaining(string filename)
{
var dir = AppContext.BaseDirectory;
while (dir != null)
{
if (File.Exists(Path.Combine(dir, filename)))
{
return dir;
}
dir = Directory.GetParent(dir)?.FullName;
}
throw new InvalidOperationException($"Could not find any ancestor directory containing {filename} at or above {AppContext.BaseDirectory}");
}
}
}