Skip to content
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

Update samples to the latest packages #9

Merged
merged 5 commits into from
May 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

In the next version of ASP.NET we are working with multiple teams around Microsoft to create a lean, composable .NET stack that provides a familiar and modern framework for web and cloud scenarios.

The Preview repository is a place for the ASP.NET Insiders to log issues and discuss ASP.NET vNext with the product team. It contains some samples and some documentation in the [wiki](https://github.com/aspnet/Home/wiki).
The Home repository is the starting point for people to learn about ASP.NET vNext, it contains samples and [documentation](https://github.com/aspnet/Home/wiki) to help folks get started and learn more about what we are doing.
The Home repository is the starting point for people to learn about ASP.NET vNext, it contains samples and [documentation](https://github.com/aspnet/Home/wiki) to help folks get started and learn more about what we are doing.

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 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 some of the new features. The NuGet.config file in the repo points to a MyGet feed that has all the packages being developed. The feed is updated every time a full build succeeds.

#Getting Started

The first thing we need to do is setup the tools required to build and run an application.
The first thing we need to do is setup the tools required to build and run an application. We will start out by getting the [K Version Manager (KVM)](https://github.com/aspnet/Home/wiki/version-manager)

* Clone the repository
* On the command line execute ```kvm setup```
* This command will download the latest version of the SDK and put it on your path so that you can run the rest of the commands in the readme. If you want to know more about what this is doing then you can read the [KVM page](https://github.com/aspnet/Home/wiki/version-manager) of the wiki.
* On the command line execute ```kvmsetup.cmd```
* This command will setup your environment, getting it ready to install a version of the runtime. It adds kvm to your path and puts it in your user profile.
* Execute ```kvm upgrade```. This command will download the latest version of the SDK and put it on your user profile ready to use. You could also install a specific version here instead of getting the latest, see the [KVM page](https://github.com/aspnet/Home/wiki/version-manager)
* Navigate to samples\HelloConsole
* Run ```K run```
* You should see some compiler output and a message saying "Hello World"
Expand All @@ -23,25 +25,25 @@ The first thing we need to do is setup the tools required to build and run an ap

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.

+ [ConsoleApp](https://github.com/aspnet/Home/tree/master/samples/ConsoleApp). 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
+ [ConsoleApp](https://github.com/aspnet/Home/tree/master/samples/ConsoleApp). This is just basic console app if you want to use it as a starting point.
+ [HelloWeb](https://github.com/aspnet/Home/tree/master/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](https://github.com/aspnet/Home/tree/master/samples/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.

**NOTE: The samples are pinned to a specific version of the packages. If you want to try the latest builds then update the project.json and replace the number at the end of the version with a '\*', so '0.1-alpha-267' becomes '0.1-alpha-\*', and then run ```K restore``` to pull down the latest packages**
**NOTE: The samples are pinned to a specific version of the packages. If you want to try the latest builds then update the project.json and replace the last part of the version with a '\*', so '0.1-alpha-build-267' becomes '0.1-alpha-\*', and then run ```kpm restore``` to pull down the latest packages**

##Feature Samples
The [Entropy repo](https://github.com/aspnet/Entropy) contains samples of specific features in isolation. Each directory contains just enough code to show an aspect of a feature.

##Application Samples
[MVC Music Store](https://github.com/aspnet/MusicStore) and [BugTracker](https://github.com/aspnet/BugTracker) application are both being ported. Each of these have their own repository that you can look at. Both of these should be mostly working, but some changes are still being made.
[MVC Music Store](https://github.com/aspnet/MusicStore) and [BugTracker](https://github.com/aspnet/BugTracker) application are both being ported. Each of these have their own repository that you can look at.

#Running the samples

##Running HelloWeb

1. Clone the repository
2. Change directory to Preview\Samples\HelloWeb
3. Run ```K restore```
2. Change directory to Samples\HelloWeb
3. Run ```kpm restore```
4. You should see a bunch of output as all the dependencies of the app are downloaded from MyGet. The K commands all operate on the app that is in the current directory.
5. Run ```K web```
6. You should see build output and a message to show the site is now started
Expand All @@ -50,7 +52,7 @@ The [Entropy repo](https://github.com/aspnet/Entropy) contains samples of specif
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. You should run ```K restore``` before using any sample for the first time.
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. You should run ```kpm restore``` before using any sample for the first time.

#Switching to Core CLR

Expand Down
189 changes: 5 additions & 184 deletions kvm.cmd
Original file line number Diff line number Diff line change
@@ -1,187 +1,8 @@
@ECHO OFF
IF "%1"=="" (
CALL :cmd_help
) ELSE (
CALL :cmd_%1 %*
IF ERRORLEVEL 1 CALL:cmd_help
)
GOTO:EOF


:cmd_setup
SET "_KVM_PATH=%USERPROFILE%\.k\"
SET "_TEMP_PATH=%PATH%"

IF /I NOT "%~dp0"=="%_KVM_PATH%" (
IF NOT EXIST "%_KVM_PATH%" MKDIR "%_KVM_PATH%"
COPY "%~f0" "%_KVM_PATH%kvm.cmd"
)

:PARSE_START
@IF "%_TEMP_PATH%"=="" GOTO PARSE_END
@FOR /F "tokens=1* delims=;" %%a in ("%_TEMP_PATH%") Do @IF "%%a"=="%_KVM_PATH%" GOTO:end_setup
@FOR /F "tokens=1* delims=;" %%a in ("%_TEMP_PATH%") Do @SET _TEMP_PATH=%%b
@GOTO PARSE_START
:PARSE_END

SET "PATH=%PATH%;%_KVM_PATH%"
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Environment]::SetEnvironmentVariable('PATH',[Environment]::GetEnvironmentVariable('PATH','user')+';%_KVM_PATH%','user');"


:end_setup
CALL "%_KVM_PATH%kvm.cmd" upgrade
@ECHO Running crossgen, see crossgen.log for results
CALL "%_KVM_PATH%k.cmd" crossgen >crossgen.log 2>crossgen.err.log
SET _KVM_PATH=
SET _TEMP_PATH=
GOTO:EOF


:cmd_upgrade
CALL:cmd_install install
CALL:cmd_alias alias default %_KVM_VERSION%
GOTO:EOF


:cmd_install
IF NOT EXIST "%~dp0.nuget\NuGet.exe" (
IF NOT EXIST "%~dp0.nuget" MKDIR "%~dp0.nuget"
ECHO Downloading latest version of NuGet.exe...
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "((new-object net.webclient).DownloadFile('https://nuget.org/nuget.exe', '%~dp0.nuget\NuGet.exe'))"
)

IF NOT EXIST "%~dp0.nuget\NuGet.config" (
echo ^<configuration^> >"%~dp0.nuget\NuGet.config"
echo ^<packageSources^> >>"%~dp0.nuget\NuGet.config"
echo ^<add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/api/v2" /^> >>"%~dp0.nuget\NuGet.config"
echo ^</packageSources^> >>"%~dp0.nuget\NuGet.config"
echo ^<packageSourceCredentials^> >>"%~dp0.nuget\NuGet.config"
echo ^<AspNetVNext^> >>"%~dp0.nuget\NuGet.config"
echo ^<add key="Username" value="aspnetreadonly" /^> >>"%~dp0.nuget\NuGet.config"
echo ^<add key="ClearTextPassword" value="4d8a2d9c-7b80-4162-9978-47e918c9658c" /^> >>"%~dp0.nuget\NuGet.config"
echo ^</AspNetVNext^> >>"%~dp0.nuget\NuGet.config"
echo ^</packageSourceCredentials^> >>"%~dp0.nuget\NuGet.config"
echo ^</configuration^> >>"%~dp0.nuget\NuGet.config"
)

IF "%2"=="" (
echo Finding latest version
FOR /f "tokens=1,2" %%G in ('"%~dp0.nuget\NuGet.exe" list ProjectK -Prerelease -ConfigFile %~dp0.nuget\NuGet.config') DO (
IF "%%G"=="ProjectK" (
SET _KVM_VERSION=%%H
)
)
) ELSE (
SET "_KVM_VERSION=%2"
)

ECHO Downloading version %_KVM_VERSION%
"%~dp0.nuget\NuGet.exe" install ProjectK -Version %_KVM_VERSION% -OutputDirectory "%~dp0packages" -ConfigFile "%~dp0.nuget\NuGet.config"
@Echo off

CALL:cmd_use use %_KVM_VERSION%
GOTO:EOF
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0kvm.ps1' %*"


:cmd_use
IF NOT EXIST "%~dp0k.cmd" (
ECHO @CALL %%~dp0kvm.cmd k %%* >%~dp0k.cmd
)
IF EXIST "%~dp0alias\%2.txt" (
FOR /F %%G IN (%~dp0alias\%2.txt) DO (
ECHO Setting _KVM_VERSION to '%%G'
SET "_KVM_VERSION=%%G"
)
) ELSE (
IF NOT EXIST "%~dp0packages\ProjectK.%2\tools\k.cmd" (
ECHO Version '%2' not found.
ECHO You may need to run 'kvm install %2'
GOTO:EOF
)
ECHO Setting _KVM_VERSION to '%2'
SET "_KVM_VERSION=%2"
)
GOTO:EOF


:cmd_alias
IF NOT EXIST "%~dp0alias" (
MKDIR "%~dp0alias"
IF EXIST "%USERPROFILE%\.kre\run-once.cmd" (
CALL "%USERPROFILE%\.kre\run-once.cmd"
DEL "%USERPROFILE%\.kre\run-once.cmd"
)
IF "%3"=="" (
IF "%2"=="" (
DIR "%~dp0alias" /b
) ELSE (
ECHO Alias '%2' is
TYPE "%~dp0alias\%2.txt"
)
) ELSE (
IF NOT EXIST "%~dp0packages\ProjectK.%3\tools\k.cmd" (
ECHO Version '%3' not found.
ECHO You may need to run 'kvm install %3'
GOTO:EOF
)

ECHO Setting alias '%2' to '%3'
ECHO %3>%~dp0alias\%2.txt
)
GOTO:EOF


:cmd_list
dir /b "%~dp0packages\ProjectK*"
GOTO:EOF


:cmd_k
@REM find k.cmd in local paths

@REM read _KVM_VERSION.txt if _KVM_VERSION not set
IF "%_KVM_VERSION%" == "" (
FOR /F %%G IN (%~dp0alias\default.txt) DO (
SET "_KVM_VERSION=%%G"
)
)
IF NOT EXIST "%~dp0packages\ProjectK.%_KVM_VERSION%\tools\k.cmd" (
ECHO Version '%_KVM_VERSION%' not found.
ECHO You may need to run 'kvm install %_KVM_VERSION%'
) ELSE (
CALL "%~dp0packages\ProjectK.%_KVM_VERSION%\tools\k.cmd" %2 %3 %4 %5 %6 %7 %8 %9
)
GOTO:EOF


:cmd_help
ECHO kvm ^<command^> [args...]
ECHO k version manager
ECHO .
ECHO kvm help
ECHO displays this help
ECHO .
ECHO kvm upgrade
ECHO install latest k version and make it the default
ECHO .
ECHO kvm install ^<version^>
ECHO install and use specific k version
ECHO .
ECHO kvm list
ECHO list installed k versions
ECHO .
ECHO kvm use ^<version^>^|^<alias^>
ECHO use a version or alias within the current command prompt
ECHO .
ECHO kvm alias ^<alias^> ^<version^>
ECHO create alias to a specific version
ECHO alias names may be passed to 'kvm use ^<alias^>'
ECHO the alias 'default' determines the default k version
ECHO when kvm use is not called
ECHO .
ECHO kvm alias ^<alias^>
ECHO show the version of an alias
ECHO .
ECHO kvm alias
ECHO list aliases
ECHO .

GOTO:EOF


Loading