parent
56fc40dbca
commit
d1b745f249
|
|
@ -1,6 +1,6 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2027
|
||||
VisualStudioVersion = 15.0.27130.2036
|
||||
MinimumVisualStudioVersion = 15.0.26124.0
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Templates.Test", "test\Templates.Test\Templates.Test.csproj", "{D43A4D24-D514-44C2-9438-54F6EDF58680}"
|
||||
EndProject
|
||||
|
|
@ -21,6 +21,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{F34CD7D7
|
|||
build\sources.props = build\sources.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{342602FC-9FF3-448D-B12D-F0E91B23DBBF}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
test\Directory.Build.targets = test\Directory.Build.targets
|
||||
test\GenerateTestProps.targets = test\GenerateTestProps.targets
|
||||
test\TemplateTests.props.in = test\TemplateTests.props.in
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -52,6 +59,7 @@ Global
|
|||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{D43A4D24-D514-44C2-9438-54F6EDF58680} = {342602FC-9FF3-448D-B12D-F0E91B23DBBF}
|
||||
{ABC9D95C-7FBD-4F8D-827A-00942EA3D0C0} = {0AD6E692-E423-408C-B523-DAFB19412E4B}
|
||||
{402E62D1-7FD0-4E07-812C-0E385D98D6D9} = {0AD6E692-E423-408C-B523-DAFB19412E4B}
|
||||
{1731F6D9-1DFC-49D6-8F28-471194B1962C} = {0AD6E692-E423-408C-B523-DAFB19412E4B}
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
<MicrosoftNETCoreApp20PackageVersion>2.0.0</MicrosoftNETCoreApp20PackageVersion>
|
||||
<MicrosoftNETCoreApp21PackageVersion>2.1.0-preview2-26326-03</MicrosoftNETCoreApp21PackageVersion>
|
||||
<MicrosoftNETTestSdkPackageVersion>15.6.1</MicrosoftNETTestSdkPackageVersion>
|
||||
<MicrosoftNETSdkRazorPackageVersion>2.1.0-preview2-30504</MicrosoftNETSdkRazorPackageVersion>
|
||||
<MicrosoftVisualStudioWebBrowserLinkPackageVersion>2.1.0-preview2-30504</MicrosoftVisualStudioWebBrowserLinkPackageVersion>
|
||||
<MicrosoftVisualStudioWebCodeGenerationDesignPackageVersion>2.1.0-preview2-30504</MicrosoftVisualStudioWebCodeGenerationDesignPackageVersion>
|
||||
<SeleniumFirefoxWebDriverPackageVersion>0.19.0</SeleniumFirefoxWebDriverPackageVersion>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<Target Name="GenerateTestProps" BeforeTargets="CoreCompile">
|
||||
<Sdk_GenerateFileFromTemplate
|
||||
TemplateFile="$(MSBuildThisFileDirectory)TemplateTests.props.in"
|
||||
Properties="RestoreSources=$([MSBuild]::Escape($(RestoreSources)));RuntimeFrameworkVersion=$(RuntimeFrameworkVersion)"
|
||||
Properties="RestoreSources=$([MSBuild]::Escape($(RestoreSources)));RuntimeFrameworkVersion=$(RuntimeFrameworkVersion);MicrosoftNETSdkRazorPackageVersion=$(MicrosoftNETSdkRazorPackageVersion)"
|
||||
OutputPath="$(OutputPath)TemplateTests.props" />
|
||||
</Target>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@
|
|||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<RestoreSources>${RestoreSources}</RestoreSources>
|
||||
<RuntimeFrameworkVersion>${RuntimeFrameworkVersion}</RuntimeFrameworkVersion>
|
||||
<MicrosoftNETSdkRazorPackageVersion>${MicrosoftNETSdkRazorPackageVersion}</MicrosoftNETSdkRazorPackageVersion>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ namespace Templates.Test
|
|||
protected string ProjectGuid { get; set; }
|
||||
protected string TemplateOutputDir { get; set; }
|
||||
protected ITestOutputHelper Output { get; private set; }
|
||||
protected bool UseRazorSdkPackage { get; set; } = true;
|
||||
|
||||
public TemplateTestBase(ITestOutputHelper output)
|
||||
{
|
||||
|
|
@ -39,7 +40,15 @@ namespace Templates.Test
|
|||
// We don't want any of the host repo's build config interfering with
|
||||
// how the test project is built, so disconnect it from the
|
||||
// Directory.Build.props/targets context
|
||||
File.WriteAllText(Path.Combine(TemplateOutputDir, "Directory.Build.props"), "<Project><Import Project=\"../../TemplateTests.props\" /></Project>");
|
||||
|
||||
var templatesTestsPropsFilePath = Path.Combine(basePath, "TemplateTests.props");
|
||||
var directoryBuildPropsContent =
|
||||
$@"<Project>
|
||||
<Import Project=""{templatesTestsPropsFilePath}"" />
|
||||
<Import Project=""Directory.Build.After.props"" Condition=""Exists('Directory.Build.After.props')"" />
|
||||
</Project>";
|
||||
|
||||
File.WriteAllText(Path.Combine(TemplateOutputDir, "Directory.Build.props"), directoryBuildPropsContent);
|
||||
File.WriteAllText(Path.Combine(TemplateOutputDir, "Directory.Build.targets"), "<Project />");
|
||||
}
|
||||
|
||||
|
|
@ -50,6 +59,8 @@ namespace Templates.Test
|
|||
|
||||
protected void RunDotNetNew(string templateName, string targetFrameworkOverride, string auth = null, string language = null, bool useLocalDB = false, bool noHttps = false)
|
||||
{
|
||||
SetAfterDirectoryBuildPropsContents();
|
||||
|
||||
var args = $"new {templateName}";
|
||||
|
||||
if (!string.IsNullOrEmpty(targetFrameworkOverride))
|
||||
|
|
@ -85,6 +96,32 @@ namespace Templates.Test
|
|||
}
|
||||
}
|
||||
|
||||
protected void SetAfterDirectoryBuildPropsContents()
|
||||
{
|
||||
var content = GetAfterDirectoryBuildPropsContent();
|
||||
if (!string.IsNullOrEmpty(content))
|
||||
{
|
||||
content = "<Project>" + Environment.NewLine + content + Environment.NewLine + "</Project>";
|
||||
File.WriteAllText(Path.Combine(TemplateOutputDir, "Directory.Build.After.props"), content);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string GetAfterDirectoryBuildPropsContent()
|
||||
{
|
||||
var content = string.Empty;
|
||||
if (UseRazorSdkPackage)
|
||||
{
|
||||
content +=
|
||||
@"
|
||||
<ItemGroup>
|
||||
<PackageReference Include=""Microsoft.NET.Sdk.Razor"" Version=""$(MicrosoftNETSdkRazorPackageVersion)"" />
|
||||
</ItemGroup>
|
||||
";
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
protected void RunDotNet(string arguments)
|
||||
{
|
||||
lock (DotNetNewLock)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace Templates.Test
|
|||
public void WebApiTemplate_Works_NetFramework()
|
||||
=> WebApiTemplateImpl("net461");
|
||||
|
||||
[Fact(Skip = "https://github.com/aspnet/templating/issues/400")]
|
||||
[Fact]
|
||||
public void WebApiTemplate_Works_NetCore()
|
||||
=> WebApiTemplateImpl(null);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue