Skip to content

Commit 52563e3

Browse files
committed
Initial checkin of some samples and a readme
1 parent b3ce7be commit 52563e3

File tree

14 files changed

+346
-0
lines changed

14 files changed

+346
-0
lines changed

K.cmd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
@ECHO OFF
2+
3+
SETLOCAL ENABLEDELAYEDEXPANSION
4+
5+
SET CURRDIR=%CD%
6+
SET PARENTDIR=!CURRDIR!
7+
8+
:START
9+
IF EXIST !CURRDIR!\packages\ProjectK* FOR /F %%I IN ('DIR !CURRDIR!\packages\ProjectK* /B /O:-D') DO (SET ProjectKDir=%%I& GOTO :ENDFOR)
10+
:ENDFOR
11+
12+
SET LocalKCmd=!CURRDIR!\packages\!ProjectKDir!\tools\k.cmd
13+
14+
IF NOT EXIST !LocalKCmd! (
15+
CALL :RESOLVE "!CURRDIR!\.." PARENTDIR
16+
IF !CURRDIR!==!PARENTDIR! (
17+
ECHO Unable to locate the ProjectK runtime
18+
ENDLOCAL & EXIT /b 1
19+
) ELSE (
20+
SET CURRDIR=!PARENTDIR!
21+
GOTO :START
22+
)
23+
)
24+
25+
CALL "!LocalKCmd!" %*
26+
ENDLOCAL & EXIT /b %ERRORLEVEL%
27+
28+
:RESOLVE
29+
SET %2=%~f1
30+
GOTO :EOF

NuGet.Config

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/" />
5+
<add key="NuGet.org" value="https://nuget.org/api/v2/" />
6+
</packageSources>
7+
<packageSourceCredentials>
8+
<AspNetVNext>
9+
<add key="Username" value="aspnetreadonly" />
10+
<add key="ClearTextPassword" value="4d8a2d9c-7b80-4162-9978-47e918c9658c" />
11+
</AspNetVNext>
12+
</packageSourceCredentials>
13+
</configuration>

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#What is this?
2+
3+
The Preview repository is a place for the ASP.NET Insiders to log issues and discuss ASP.NET vNext with the product team.
4+
5+
The samples provided are designed to show some of the features of the new framework as well as setting up a sandbox for you to try out new drops of functionality as they come out. The NuGet.config file in the repo points to a private MyGet feed that has all the packages being developed. The feed is updated every time a full build succeeds.
6+
7+
**The K.cmd file in the root of this repo is designed to be able to be put in your path. It will probe various locations relative to your current directory to find the KRuntime that it should" use. All the examples after this will assume you've done this, so that you can just type K Run from anywhere. If you choose not to then add the appropriate number of folder traversals (..\\) before each K command.**
8+
9+
#Available Sample
10+
11+
##Sandbox Samples
12+
13+
These samples, in this repo, are just basic starting points for you to experiment with features. Since there is no File->New Project we thought some simple samples to take the place of scaffolding would be convenient.
14+
15+
+ HelloConsole. This is just basic console app if you want to use it as a starting point. Use it the same as the console app from our earlier samples
16+
+ HelloWeb. This is a minimal startup class that shows welcome page and static file middleware. This is mostly for you to run through the steps in the readme and make sure you have everything setup and working correctly.
17+
+ HelloWebFx. This sample is a basic MVC app. It is not designed to show all the functionality of the new web stack, but to give you a starting point to play with features.
18+
19+
##Feature Samples
20+
The Entropy repo contains examples of specific features in isolation. Each directory contains just enough code to show an aspect of a feature.
21+
22+
##Application Samples
23+
MVC Music Store and BugTracker application are both being ported. Each of these have their own repository that you can look at as they are working.
24+
25+
#Running the samples
26+
27+
1. Clone the repository
28+
2. Change directory to Preview\Samples\HelloWeb
29+
3. Run "K restore"
30+
4. You should see a bunch of output as all the dependencies of the app are downloaded from MyGet. This may take a while if MyGet is slow.
31+
5. Run "K web"
32+
6. You should see build output and a message to show the site is now started
33+
7. Navigate to "http://localhost:5001"
34+
8. You should see the welcome page
35+
9. Navigate to "http://localhost:5001/image.jpg"
36+
10. You should see an image served with the static file middleware
37+
38+
If you can do all of the above then everything should be working. You can try out the WebFx sample now to see some more of the new stack.
39+
40+
#Switching to Core CLR
41+
42+
By default when running the applications you are running against Desktop CLR (4.5), you can change that by setting the TARGET_FRAMEWORK variable:
43+
44+
1. Run "set TARGET_FRAMEWORK=k10"
45+
2. Run "K web"
46+
3. The first line of your output should say "Loaded Module: klr.core45.dll" instead of "Loaded Module: klr.net45.dll"
47+
4. The HelloWeb app should work the same as when running on Desktop CLR.
48+
49+
**NOTE: There are going to be parts of the stack that work on Desktop but do not work on Core CLR. This set should get smaller and smaller as time goes on, but it is entirely likely as you use Core CLR you will hit errors that can't be worked around as the Core CLR surface area just does not exist yet. An example of this type of problem is using EF with a database. There are not currently any real database providers that work on Core CLR, so you will be restricted to in-memory EF on Core CLR.**
50+
51+
#Packages in the repository
52+
53+
Installing packages from MyGet can be very slow. In order to save the time of getting the Runtime itself, which is the largest of our packages, we checked it in. We will update it periodically as important features are added. The package is also on MyGet if you want to get the latest version yourself.
54+
55+
#Core CLR Packages
56+
57+
Currently the BCL is broken into some fairly fine grained packages, which was one of the goals of this effort. However, the packages that exist today do not necesarilly represent the list of packages that we will end up with. We are still experimenting with what makes sense to be a package and what the experience should be.

samples/ConsoleApp/Program.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
public class Program
4+
{
5+
public static void Main()
6+
{
7+
Console.WriteLine("Hello World");
8+
}
9+
}

samples/ConsoleApp/project.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"dependencies" : {
3+
},
4+
"configurations": {
5+
"net45" : {},
6+
"k10": {
7+
"dependencies": {
8+
"System.Runtime": "4.0.20.0",
9+
"System.Console": "4.0.0.0"
10+
}
11+
}
12+
}
13+
}

samples/HelloWeb/Startup.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.AspNet.Abstractions;
2+
using Microsoft.AspNet;
3+
4+
namespace KWebStartup
5+
{
6+
public class Startup
7+
{
8+
public void Configuration(IBuilder app)
9+
{
10+
app.UseStaticFiles();
11+
app.UseWelcomePage();
12+
}
13+
}
14+
}

samples/HelloWeb/image.jpg

303 KB
Loading

samples/HelloWeb/project.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"version": "0.1-alpha-*",
3+
"dependencies": {
4+
"Microsoft.AspNet.Abstractions": "0.1-alpha-*",
5+
"Microsoft.AspNet.Hosting": "0.1-alpha-*",
6+
"Microsoft.AspNet.Server.WebListener": "0.1-alpha-*",
7+
"Microsoft.AspNet.Diagnostics":"0.1-alpha-*",
8+
"Microsoft.AspNet.StaticFiles":"0.1-alpha-*"
9+
},
10+
"commands": { "web": "Microsoft.AspNet.Hosting server.name=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001" },
11+
"configurations": {
12+
"net45": {
13+
},
14+
"k10": {
15+
"dependencies": {
16+
"System.Console": "4.0.0.0",
17+
"System.Collections": "4.0.0.0",
18+
"System.Diagnostics.Debug": "4.0.10.0",
19+
"System.Diagnostics.Tools": "4.0.0.0",
20+
"System.Globalization": "4.0.10.0",
21+
"System.IO": "4.0.0.0",
22+
"System.IO.FileSystem": "4.0.0.0",
23+
"System.IO.FileSystem.Primitives": "4.0.0.0",
24+
"System.Linq": "4.0.0.0",
25+
"System.Reflection": "4.0.10.0",
26+
"System.Resources.ResourceManager": "4.0.0.0",
27+
"System.Runtime": "4.0.20.0",
28+
"System.Runtime.Extensions": "4.0.10.0",
29+
"System.Runtime.InteropServices": "4.0.10.0",
30+
"System.Text.Encoding": "4.0.10.0",
31+
"System.Threading.Tasks": "4.0.0.0"
32+
}
33+
}
34+
}
35+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using Microsoft.AspNet.Mvc;
2+
using MvcSample.Web.Models;
3+
4+
namespace MvcSample.Web
5+
{
6+
public class HomeController : Controller
7+
{
8+
public IActionResult Index()
9+
{
10+
return View(User());
11+
}
12+
13+
public User User()
14+
{
15+
User user = new User()
16+
{
17+
Name = "My name",
18+
Address = "My address"
19+
};
20+
21+
return user;
22+
}
23+
}
24+
}

samples/HelloWebFx/Models/User.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.ComponentModel.DataAnnotations;
2+
3+
namespace MvcSample.Web.Models
4+
{
5+
public class User
6+
{
7+
[Required]
8+
[MinLength(4)]
9+
public string Name { get; set; }
10+
public string Address { get; set; }
11+
public int Age { get; set; }
12+
}
13+
}

samples/HelloWebFx/Startup.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Microsoft.AspNet.Abstractions;
2+
using Microsoft.AspNet.DependencyInjection;
3+
using Microsoft.AspNet.DependencyInjection.Fallback;
4+
using Microsoft.AspNet.Mvc;
5+
using Microsoft.AspNet.RequestContainer;
6+
using Microsoft.AspNet.Routing;
7+
using Microsoft.AspNet.Diagnostics;
8+
using Microsoft.AspNet;
9+
10+
namespace KWebStartup
11+
{
12+
public class Startup
13+
{
14+
public void Configuration(IBuilder app)
15+
{
16+
var services = new ServiceCollection();
17+
services.Add(MvcServices.GetDefaultServices());
18+
var serviceProvider = services.BuildServiceProvider(app.ServiceProvider);
19+
20+
var routes = new RouteCollection
21+
{
22+
DefaultHandler = new MvcApplication(serviceProvider)
23+
};
24+
25+
routes.MapRoute("{controller}/{action}", new { controller = "Home", action = "Index" });
26+
27+
app.UseErrorPage();
28+
app.UseContainer(serviceProvider);
29+
app.UseRouter(routes);
30+
app.UseWelcomePage();
31+
}
32+
}
33+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@using MvcSample.Web.Models
2+
@model User
3+
@{
4+
Layout = "/Views/Shared/_Layout.cshtml";
5+
ViewBag.Title = "Home Page";
6+
string nullValue = null;
7+
}
8+
9+
<div class="jumbotron">
10+
<h1>ASP.NET</h1>
11+
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
12+
<p><a href="http://asp.net" class="btn btn-primary btn-large">Learn more &raquo;</a></p>
13+
</div>
14+
<div class="row">
15+
<h3 title="@Model.Name" class="@nullValue">Hello @Model.Name!</h3>
16+
</div>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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>@ViewBag.Title - My ASP.NET Application</title>
7+
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" />
8+
</head>
9+
<body>
10+
<div class="navbar navbar-inverse navbar-fixed-top">
11+
<div class="container">
12+
<div class="navbar-header">
13+
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
14+
<span class="icon-bar"></span>
15+
<span class="icon-bar"></span>
16+
<span class="icon-bar"></span>
17+
</button>
18+
</div>
19+
<div class="navbar-collapse collapse">
20+
<ul class="nav navbar-nav">
21+
<li><a href="/">Home</a></li>
22+
</ul>
23+
</div>
24+
</div>
25+
</div>
26+
<div class="container body-content">
27+
@RenderBody()
28+
<hr />
29+
<address>
30+
@if (@Model != null)
31+
{
32+
@Model.Address
33+
}
34+
</address>
35+
<footer>
36+
<p>&copy; @DateTime.Now.Year - My ASP.NET Application</p>
37+
</footer>
38+
</div>
39+
</body>
40+
</html>

samples/HelloWebFx/project.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"version": "0.1-alpha-*",
3+
"dependencies": {
4+
"Microsoft.AspNet.Abstractions": "0.1-alpha-*",
5+
"Microsoft.AspNet.Hosting": "0.1-alpha-*",
6+
"Microsoft.AspNet.Server.WebListener": "0.1-alpha-*",
7+
"Microsoft.AspNet.DependencyInjection": "0.1-alpha-*",
8+
"Microsoft.AspNet.RequestContainer": "0.1-alpha-*",
9+
"Microsoft.AspNet.Routing": "0.1-alpha-*",
10+
"Microsoft.ComponentModel.DataAnnotations": "4.0.10.0",
11+
"Microsoft.AspNet.Mvc.ModelBinding": "0.1-alpha-*",
12+
"Microsoft.AspNet.Mvc.Core": "0.1-alpha-*",
13+
"Microsoft.AspNet.Mvc": "0.1-alpha-*",
14+
"Microsoft.AspNet.Mvc.Razor": "0.1-alpha-*",
15+
"Microsoft.AspNet.Mvc.Rendering": "0.1-alpha-*",
16+
"Microsoft.AspNet.ConfigurationModel": "0.1-alpha-*",
17+
"Microsoft.AspNet.Diagnostics":"0.1-alpha-*"
18+
},
19+
"commands": { "web": "Microsoft.AspNet.Hosting server.name=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001" },
20+
"configurations": {
21+
"net45": {
22+
"dependencies": {
23+
"System.ComponentModel.DataAnnotations": ""
24+
}
25+
},
26+
"k10": {
27+
"dependencies": {
28+
"System.Console": "4.0.0.0",
29+
"System.Collections": "4.0.0.0",
30+
"System.Diagnostics.Debug": "4.0.10.0",
31+
"System.Diagnostics.Tools": "4.0.0.0",
32+
"System.Globalization": "4.0.10.0",
33+
"System.IO": "4.0.0.0",
34+
"System.IO.FileSystem": "4.0.0.0",
35+
"System.IO.FileSystem.Primitives": "4.0.0.0",
36+
"System.Linq": "4.0.0.0",
37+
"System.Reflection": "4.0.10.0",
38+
"System.Resources.ResourceManager": "4.0.0.0",
39+
"System.Runtime": "4.0.20.0",
40+
"System.Runtime.Extensions": "4.0.10.0",
41+
"System.Runtime.InteropServices": "4.0.10.0",
42+
"System.Text.Encoding": "4.0.10.0",
43+
"System.Threading.Tasks": "4.0.0.0",
44+
"System.ComponentModel": "4.0.0.0",
45+
"System.Dynamic.Runtime": "4.0.0.0"
46+
}
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)