-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial checkin of some samples and a readme #1
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
@ECHO OFF | ||
|
||
SETLOCAL ENABLEDELAYEDEXPANSION | ||
|
||
SET CURRDIR=%CD% | ||
SET PARENTDIR=!CURRDIR! | ||
|
||
:START | ||
IF EXIST !CURRDIR!\packages\ProjectK* FOR /F %%I IN ('DIR !CURRDIR!\packages\ProjectK* /B /O:-D') DO (SET ProjectKDir=%%I& GOTO :ENDFOR) | ||
:ENDFOR | ||
|
||
SET LocalKCmd=!CURRDIR!\packages\!ProjectKDir!\tools\k.cmd | ||
|
||
IF NOT EXIST !LocalKCmd! ( | ||
CALL :RESOLVE "!CURRDIR!\.." PARENTDIR | ||
IF !CURRDIR!==!PARENTDIR! ( | ||
ECHO Unable to locate the ProjectK runtime | ||
ENDLOCAL & EXIT /b 1 | ||
) ELSE ( | ||
SET CURRDIR=!PARENTDIR! | ||
GOTO :START | ||
) | ||
) | ||
|
||
CALL "!LocalKCmd!" %* | ||
ENDLOCAL & EXIT /b %ERRORLEVEL% | ||
|
||
:RESOLVE | ||
SET %2=%~f1 | ||
GOTO :EOF |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<packageSources> | ||
<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/" /> | ||
<add key="NuGet.org" value="https://nuget.org/api/v2/" /> | ||
</packageSources> | ||
<packageSourceCredentials> | ||
<AspNetVNext> | ||
<add key="Username" value="aspnetreadonly" /> | ||
<add key="ClearTextPassword" value="4d8a2d9c-7b80-4162-9978-47e918c9658c" /> | ||
</AspNetVNext> | ||
</packageSourceCredentials> | ||
</configuration> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#What is this? | ||
|
||
The Preview repository is a place for the ASP.NET Insiders to log issues and discuss ASP.NET vNext with the product team. | ||
|
||
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. | ||
|
||
**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.** | ||
|
||
#Available Sample | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sample_s_? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also not sure what it means to be "available" - presumably all samples are available, no? Or does this mean something special here? |
||
|
||
##Sandbox Samples | ||
|
||
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. | ||
|
||
+ 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 | ||
+ 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. | ||
+ 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. | ||
|
||
##Feature Samples | ||
The Entropy repo contains examples of specific features in isolation. Each directory contains just enough code to show an aspect of a feature. | ||
|
||
##Application Samples | ||
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. | ||
|
||
#Running the samples | ||
|
||
1. Clone the repository | ||
2. Change directory to Preview\Samples\HelloWeb | ||
3. Run "K restore" | ||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't specifically blame MyGet here - there are many causes for slowness, such as the fact that there's a lot of stuff to download 😄 |
||
5. Run "K web" | ||
6. You should see build output and a message to show the site is now started | ||
7. Navigate to "http://localhost:5001" | ||
8. You should see the welcome page | ||
9. Navigate to "http://localhost:5001/image.jpg" | ||
10. You should see an image served with the static file middleware | ||
|
||
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. | ||
|
||
#Switching to Core CLR | ||
|
||
By default when running the applications you are running against Desktop CLR (4.5), you can change that by setting the TARGET_FRAMEWORK variable: | ||
|
||
1. Run "set TARGET_FRAMEWORK=k10" | ||
2. Run "K web" | ||
3. The first line of your output should say "Loaded Module: klr.core45.dll" instead of "Loaded Module: klr.net45.dll" | ||
4. The HelloWeb app should work the same as when running on Desktop CLR. | ||
|
||
**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.** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spell out Entity Framework at least the first time. |
||
|
||
#Packages in the repository | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to blame MyGet. Just say that re-downloading it can be unnecessary. |
||
|
||
#Core CLR Packages | ||
|
||
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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace "broken" with "split". |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using System; | ||
|
||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
Console.WriteLine("Hello World"); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"dependencies" : { | ||
}, | ||
"configurations": { | ||
"net45" : {}, | ||
"k10": { | ||
"dependencies": { | ||
"System.Runtime": "4.0.20.0", | ||
"System.Console": "4.0.0.0" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.AspNet.Abstractions; | ||
using Microsoft.AspNet; | ||
|
||
namespace KWebStartup | ||
{ | ||
public class Startup | ||
{ | ||
public void Configuration(IBuilder app) | ||
{ | ||
app.UseStaticFiles(); | ||
app.UseWelcomePage(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"version": "0.1-alpha-*", | ||
"dependencies": { | ||
"Microsoft.AspNet.Abstractions": "0.1-alpha-*", | ||
"Microsoft.AspNet.Hosting": "0.1-alpha-*", | ||
"Microsoft.AspNet.Server.WebListener": "0.1-alpha-*", | ||
"Microsoft.AspNet.Diagnostics":"0.1-alpha-*", | ||
"Microsoft.AspNet.StaticFiles":"0.1-alpha-*" | ||
}, | ||
"commands": { "web": "Microsoft.AspNet.Hosting server.name=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001" }, | ||
"configurations": { | ||
"net45": { | ||
}, | ||
"k10": { | ||
"dependencies": { | ||
"System.Console": "4.0.0.0", | ||
"System.Collections": "4.0.0.0", | ||
"System.Diagnostics.Debug": "4.0.10.0", | ||
"System.Diagnostics.Tools": "4.0.0.0", | ||
"System.Globalization": "4.0.10.0", | ||
"System.IO": "4.0.0.0", | ||
"System.IO.FileSystem": "4.0.0.0", | ||
"System.IO.FileSystem.Primitives": "4.0.0.0", | ||
"System.Linq": "4.0.0.0", | ||
"System.Reflection": "4.0.10.0", | ||
"System.Resources.ResourceManager": "4.0.0.0", | ||
"System.Runtime": "4.0.20.0", | ||
"System.Runtime.Extensions": "4.0.10.0", | ||
"System.Runtime.InteropServices": "4.0.10.0", | ||
"System.Text.Encoding": "4.0.10.0", | ||
"System.Threading.Tasks": "4.0.0.0" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.AspNet.Mvc; | ||
using MvcSample.Web.Models; | ||
|
||
namespace MvcSample.Web | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
public IActionResult Index() | ||
{ | ||
return View(User()); | ||
} | ||
|
||
public User User() | ||
{ | ||
User user = new User() | ||
{ | ||
Name = "My name", | ||
Address = "My address" | ||
}; | ||
|
||
return user; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace MvcSample.Web.Models | ||
{ | ||
public class User | ||
{ | ||
[Required] | ||
[MinLength(4)] | ||
public string Name { get; set; } | ||
public string Address { get; set; } | ||
public int Age { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using Microsoft.AspNet.Abstractions; | ||
using Microsoft.AspNet.DependencyInjection; | ||
using Microsoft.AspNet.DependencyInjection.Fallback; | ||
using Microsoft.AspNet.Mvc; | ||
using Microsoft.AspNet.RequestContainer; | ||
using Microsoft.AspNet.Routing; | ||
using Microsoft.AspNet.Diagnostics; | ||
using Microsoft.AspNet; | ||
|
||
namespace KWebStartup | ||
{ | ||
public class Startup | ||
{ | ||
public void Configuration(IBuilder app) | ||
{ | ||
var services = new ServiceCollection(); | ||
services.Add(MvcServices.GetDefaultServices()); | ||
var serviceProvider = services.BuildServiceProvider(app.ServiceProvider); | ||
|
||
var routes = new RouteCollection | ||
{ | ||
DefaultHandler = new MvcApplication(serviceProvider) | ||
}; | ||
|
||
routes.MapRoute("{controller}/{action}", new { controller = "Home", action = "Index" }); | ||
|
||
app.UseErrorPage(); | ||
app.UseContainer(serviceProvider); | ||
app.UseRouter(routes); | ||
app.UseWelcomePage(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
@using MvcSample.Web.Models | ||
@model User | ||
@{ | ||
Layout = "/Views/Shared/_Layout.cshtml"; | ||
ViewBag.Title = "Home Page"; | ||
string nullValue = null; | ||
} | ||
|
||
<div class="jumbotron"> | ||
<h1>ASP.NET</h1> | ||
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p> | ||
<p><a href="http://asp.net" class="btn btn-primary btn-large">Learn more »</a></p> | ||
</div> | ||
<div class="row"> | ||
<h3 title="@Model.Name" class="@nullValue">Hello @Model.Name!</h3> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>@ViewBag.Title - My ASP.NET Application</title> | ||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" /> | ||
</head> | ||
<body> | ||
<div class="navbar navbar-inverse navbar-fixed-top"> | ||
<div class="container"> | ||
<div class="navbar-header"> | ||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
<span class="icon-bar"></span> | ||
</button> | ||
</div> | ||
<div class="navbar-collapse collapse"> | ||
<ul class="nav navbar-nav"> | ||
<li><a href="/">Home</a></li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="container body-content"> | ||
@RenderBody() | ||
<hr /> | ||
<address> | ||
@if (@Model != null) | ||
{ | ||
@Model.Address | ||
} | ||
</address> | ||
<footer> | ||
<p>© @DateTime.Now.Year - My ASP.NET Application</p> | ||
</footer> | ||
</div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"version": "0.1-alpha-*", | ||
"dependencies": { | ||
"Microsoft.AspNet.Abstractions": "0.1-alpha-*", | ||
"Microsoft.AspNet.Hosting": "0.1-alpha-*", | ||
"Microsoft.AspNet.Server.WebListener": "0.1-alpha-*", | ||
"Microsoft.AspNet.DependencyInjection": "0.1-alpha-*", | ||
"Microsoft.AspNet.RequestContainer": "0.1-alpha-*", | ||
"Microsoft.AspNet.Routing": "0.1-alpha-*", | ||
"Microsoft.ComponentModel.DataAnnotations": "4.0.10.0", | ||
"Microsoft.AspNet.Mvc.ModelBinding": "0.1-alpha-*", | ||
"Microsoft.AspNet.Mvc.Core": "0.1-alpha-*", | ||
"Microsoft.AspNet.Mvc": "0.1-alpha-*", | ||
"Microsoft.AspNet.Mvc.Razor": "0.1-alpha-*", | ||
"Microsoft.AspNet.Mvc.Rendering": "0.1-alpha-*", | ||
"Microsoft.AspNet.ConfigurationModel": "0.1-alpha-*", | ||
"Microsoft.AspNet.Diagnostics":"0.1-alpha-*" | ||
}, | ||
"commands": { "web": "Microsoft.AspNet.Hosting server.name=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001" }, | ||
"configurations": { | ||
"net45": { | ||
"dependencies": { | ||
"System.ComponentModel.DataAnnotations": "" | ||
} | ||
}, | ||
"k10": { | ||
"dependencies": { | ||
"System.Console": "4.0.0.0", | ||
"System.Collections": "4.0.0.0", | ||
"System.Diagnostics.Debug": "4.0.10.0", | ||
"System.Diagnostics.Tools": "4.0.0.0", | ||
"System.Globalization": "4.0.10.0", | ||
"System.IO": "4.0.0.0", | ||
"System.IO.FileSystem": "4.0.0.0", | ||
"System.IO.FileSystem.Primitives": "4.0.0.0", | ||
"System.Linq": "4.0.0.0", | ||
"System.Reflection": "4.0.10.0", | ||
"System.Resources.ResourceManager": "4.0.0.0", | ||
"System.Runtime": "4.0.20.0", | ||
"System.Runtime.Extensions": "4.0.10.0", | ||
"System.Runtime.InteropServices": "4.0.10.0", | ||
"System.Text.Encoding": "4.0.10.0", | ||
"System.Threading.Tasks": "4.0.0.0", | ||
"System.ComponentModel": "4.0.0.0", | ||
"System.Dynamic.Runtime": "4.0.0.0" | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous
"
in the middle of this line.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terminology is mixed: are these 'examples' or 'samples'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do regular Markdown files support the back-tick for "code" stuff? If so, do
k run
instead of K Run to make it clear it's a programmatic (i.e. command line) thing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed the extra
"
just after I sent the pull request. I've fixed it on my machine.By examples I mean the instructions in the rest of the readme, not the samples. I'll make this clearer.
Yes, the markdown supports back-tick code. I'll change them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK thanks for clarifying the terminology - wasn't sure if it was deliberate.