Skip to content

Commit 97313c7

Browse files
author
N. Taylor Mullen
committed
Only add DotNetCoreRazorConfiguration capability in SDK for netcoreapp3.0.
- Prior to this we were unconditionally adding the `DotNetCoreRazorConfiguration` capability resulting in 1.0 projects looking like 2.1+ projects. - Added a project capability test that verifies we're maintaining project capabilities for netcoreapp3.0 projects. - Added a project capability test that verifies we don't muck with 1.1 project capabilities. aspnet/Razor#2751
1 parent 4fa0dbe commit 97313c7

File tree

9 files changed

+247
-1
lines changed

9 files changed

+247
-1
lines changed

src/Razor/Microsoft.NET.Sdk.Razor/src/build/netstandard2.0/Microsoft.NET.Sdk.Razor.DesignTime.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Copyright (c) .NET Foundation. All rights reserved.
2626
Defines the ability to understand the configuration for the Razor language service provided by
2727
the runtime/toolset packages. Introduced in 2.1
2828
-->
29-
<ProjectCapability Include="DotNetCoreRazorConfiguration"/>
29+
<ProjectCapability Include="DotNetCoreRazorConfiguration" Condition="'$(_TargetingNETCoreApp30OrLater)'=='true'"/>
3030
</ItemGroup>
3131

3232
<!--

src/Razor/Microsoft.NET.Sdk.Razor/test/IntegrationTests/BuildIntrospectionTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,28 @@ public BuildIntrospectionTest(BuildServerTestFixture buildServer)
1414
{
1515
}
1616

17+
[Fact]
18+
[InitializeTestProject("SimpleMvc11")]
19+
public async Task RazorSdk_DoesNotAddCoreRazorConfigurationTo11Projects()
20+
{
21+
var result = await DotnetMSBuild("_IntrospectProjectCapabilityItems");
22+
23+
Assert.BuildPassed(result);
24+
Assert.BuildOutputContainsLine(result, "ProjectCapability: DotNetCoreRazor");
25+
Assert.BuildOutputDoesNotContainLine(result, "ProjectCapability: DotNetCoreRazorConfiguration");
26+
}
27+
28+
[Fact]
29+
[InitializeTestProject("SimpleMvc")]
30+
public async Task RazorSdk_AddsProjectCapabilities()
31+
{
32+
var result = await DotnetMSBuild("_IntrospectProjectCapabilityItems");
33+
34+
Assert.BuildPassed(result);
35+
Assert.BuildOutputContainsLine(result, "ProjectCapability: DotNetCoreRazor");
36+
Assert.BuildOutputContainsLine(result, "ProjectCapability: DotNetCoreRazorConfiguration");
37+
}
38+
1739
[Fact]
1840
[InitializeTestProject("SimpleMvc")]
1941
public async Task RazorSdk_AddsCshtmlFilesToUpToDateCheckInput()

src/Razor/test/testassets/RazorTest.Introspection.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@
2525
<Target Name="_IntrospectGetCopyToOutputDirectoryItems">
2626
<Message Text="AllItemsFullPathWithTargetPath: %(AllItemsFullPathWithTargetPath.TargetPath)" Importance="High" />
2727
</Target>
28+
29+
<Target Name="_IntrospectProjectCapabilityItems">
30+
<Message Text="ProjectCapability: %(ProjectCapability.Identity)" Importance="High" />
31+
</Target>
2832
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+

2+
namespace SimpleMvc11
3+
{
4+
public class Program
5+
{
6+
public static void Main(string[] args)
7+
{
8+
// Just make sure we have a reference to MVC 1.1
9+
var t = typeof(Microsoft.AspNetCore.Mvc.IActionResult);
10+
System.Console.WriteLine(t.FullName);
11+
}
12+
}
13+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<!--
4+
This project references a shipped version of MVC and should not reference local builds of
5+
the CodeGeneration targets, rzc, or any of the test shims.
6+
-->
7+
8+
9+
<PropertyGroup>
10+
<TargetFramework>netcoreapp1.1</TargetFramework>
11+
</PropertyGroup>
12+
13+
<!-- Test Placeholder -->
14+
15+
<ItemGroup>
16+
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.7" />
17+
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.8">
18+
<!-- Avoid exporting types from real MVC that will conflict with the test shim -->
19+
<PrivateAssets>All</PrivateAssets>
20+
</PackageReference>
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
@{
2+
ViewData["Title"] = "Home Page";
3+
}
4+
5+
<div id="myCarousel" class="carousel slide" data-ride="carousel" data-interval="6000">
6+
<ol class="carousel-indicators">
7+
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
8+
<li data-target="#myCarousel" data-slide-to="1"></li>
9+
<li data-target="#myCarousel" data-slide-to="2"></li>
10+
<li data-target="#myCarousel" data-slide-to="3"></li>
11+
</ol>
12+
<div class="carousel-inner" role="listbox">
13+
<div class="item active">
14+
<img src="~/images/banner1.svg" alt="ASP.NET" class="img-responsive" />
15+
<div class="carousel-caption" role="option">
16+
<p>
17+
Learn how to build ASP.NET apps that can run anywhere.
18+
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525028&clcid=0x409">
19+
Learn More
20+
</a>
21+
</p>
22+
</div>
23+
</div>
24+
<div class="item">
25+
<img src="~/images/banner2.svg" alt="Visual Studio" class="img-responsive" />
26+
<div class="carousel-caption" role="option">
27+
<p>
28+
There are powerful new features in Visual Studio for building modern web apps.
29+
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525030&clcid=0x409">
30+
Learn More
31+
</a>
32+
</p>
33+
</div>
34+
</div>
35+
<div class="item">
36+
<img src="~/images/banner3.svg" alt="Package Management" class="img-responsive" />
37+
<div class="carousel-caption" role="option">
38+
<p>
39+
Bring in libraries from NuGet, Bower, and npm, and automate tasks using Grunt or Gulp.
40+
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525029&clcid=0x409">
41+
Learn More
42+
</a>
43+
</p>
44+
</div>
45+
</div>
46+
<div class="item">
47+
<img src="~/images/banner4.svg" alt="Microsoft Azure" class="img-responsive" />
48+
<div class="carousel-caption" role="option">
49+
<p>
50+
Learn how Microsoft's Azure cloud platform allows you to build, deploy, and scale web apps.
51+
<a class="btn btn-default" href="https://go.microsoft.com/fwlink/?LinkID=525027&clcid=0x409">
52+
Learn More
53+
</a>
54+
</p>
55+
</div>
56+
</div>
57+
</div>
58+
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
59+
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
60+
<span class="sr-only">Previous</span>
61+
</a>
62+
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
63+
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
64+
<span class="sr-only">Next</span>
65+
</a>
66+
</div>
67+
68+
<div class="row">
69+
<div class="col-md-3">
70+
<h2>Application uses</h2>
71+
<ul>
72+
<li>Sample pages using ASP.NET Core MVC</li>
73+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518004">Bower</a> for managing client-side libraries</li>
74+
<li>Theming using <a href="https://go.microsoft.com/fwlink/?LinkID=398939">Bootstrap</a></li>
75+
</ul>
76+
</div>
77+
<div class="col-md-3">
78+
<h2>How to</h2>
79+
<ul>
80+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398600">Add a Controller and View</a></li>
81+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699315">Manage User Secrets using Secret Manager.</a></li>
82+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699316">Use logging to log a message.</a></li>
83+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699317">Add packages using NuGet.</a></li>
84+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699318">Add client packages using Bower.</a></li>
85+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699319">Target development, staging or production environment.</a></li>
86+
</ul>
87+
</div>
88+
<div class="col-md-3">
89+
<h2>Overview</h2>
90+
<ul>
91+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=518008">Conceptual overview of what is ASP.NET Core</a></li>
92+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=699320">Fundamentals of ASP.NET Core such as Startup and middleware.</a></li>
93+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398602">Working with Data</a></li>
94+
<li><a href="https://go.microsoft.com/fwlink/?LinkId=398603">Security</a></li>
95+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699321">Client side development</a></li>
96+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699322">Develop on different platforms</a></li>
97+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=699323">Read more on the documentation site</a></li>
98+
</ul>
99+
</div>
100+
<div class="col-md-3">
101+
<h2>Run &amp; Deploy</h2>
102+
<ul>
103+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517851">Run your app</a></li>
104+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=517853">Run tools such as EF migrations and more</a></li>
105+
<li><a href="https://go.microsoft.com/fwlink/?LinkID=398609">Publish to Microsoft Azure Web Apps</a></li>
106+
</ul>
107+
</div>
108+
</div>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>@ViewData["Title"] - SimpleMvc11</title>
7+
8+
<environment names="Development">
9+
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
10+
<link rel="stylesheet" href="~/css/site.css" />
11+
</environment>
12+
<environment names="Staging,Production">
13+
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/css/bootstrap.min.css"
14+
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
15+
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
16+
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
17+
</environment>
18+
</head>
19+
<body>
20+
<nav class="navbar navbar-inverse navbar-fixed-top">
21+
<div class="container">
22+
<div class="navbar-header">
23+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
24+
<span class="sr-only">Toggle navigation</span>
25+
<span class="icon-bar"></span>
26+
<span class="icon-bar"></span>
27+
<span class="icon-bar"></span>
28+
</button>
29+
<a asp-area="" asp-controller="Home" asp-action="Index" class="navbar-brand">SimpleMvc11</a>
30+
</div>
31+
<div class="navbar-collapse collapse">
32+
<ul class="nav navbar-nav">
33+
<li><a asp-area="" asp-controller="Home" asp-action="Index">Home</a></li>
34+
<li><a asp-area="" asp-controller="Home" asp-action="About">About</a></li>
35+
<li><a asp-area="" asp-controller="Home" asp-action="Contact">Contact</a></li>
36+
</ul>
37+
</div>
38+
</div>
39+
</nav>
40+
<div class="container body-content">
41+
@RenderBody()
42+
<hr />
43+
<footer>
44+
<p>&copy; 2018 - SimpleMvc11</p>
45+
</footer>
46+
</div>
47+
48+
<environment names="Development">
49+
<script src="~/lib/jquery/dist/jquery.js"></script>
50+
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
51+
<script src="~/js/site.js" asp-append-version="true"></script>
52+
</environment>
53+
<environment names="Staging,Production">
54+
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.0.min.js"
55+
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
56+
asp-fallback-test="window.jQuery"
57+
crossorigin="anonymous"
58+
integrity="sha384-K+ctZQ+LL8q6tP7I94W+qzQsfRV2a+AfHIi9k8z8l9ggpc8X+Ytst4yBo/hH+8Fk">
59+
</script>
60+
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.7/bootstrap.min.js"
61+
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
62+
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
63+
crossorigin="anonymous"
64+
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa">
65+
</script>
66+
<script src="~/js/site.min.js" asp-append-version="true"></script>
67+
</environment>
68+
69+
@RenderSection("Scripts", required: false)
70+
</body>
71+
</html>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@using SimpleMvc11
2+
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@{
2+
Layout = "_Layout";
3+
}

0 commit comments

Comments
 (0)