diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000000..5c926f686677 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,22 @@ +To address your issues more quickly, please open the issue in the most appropriate repository. These are some of the most common repos: + +Common ASP.NET and Entity Framework repos and projects: + + - Documentation: https://github.com/aspnet/Docs + - MVC: https://github.com/aspnet/Mvc + - Entity Framework Core: https://github.com/aspnet/EntityFramework + - Entity Framework 6: https://github.com/aspnet/EntityFramework6 + - SignalR: https://github.com/aspnet/SignalR + - ASP.NET Core in Docker: https://github.com/aspnet/aspnet-docker + - Microsoft.NET.Sdk.Web: https://github.com/aspnet/websdk + - Kestrel HTTP Server: https://github.com/aspnet/KestrelHttpServer + - ASP.NET Katana: https://github.com/aspnet/AspNetKatana + - and more! See a full list here: https://github.com/aspnet + +Other common projects: + + - NuGet: https://github.com/NuGet/home + - .NET Core CLI, SDK, or runtime: https://github.com/dotnet/core + - Visual Studio: https://developercommunity.visualstudio.com + - Visual Studio Code: https://github.com/microsoft/vscode + - Omnisharp (C# support for VS Code): https://github.com/omnisharp/omnisharp-vscode diff --git a/.gitignore b/.gitignore index 8bc217058d9b..ec80ffa90732 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ [Bb]in/ TestResults/ .nuget/ +.vs/ _ReSharper.*/ packages/ artifacts/ @@ -21,4 +22,6 @@ nuget.exe *DS_Store *.ncrunchsolution *.*sdf -*.ipch \ No newline at end of file +*.ipch +*.sln.ide +project.lock.json \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e23e36ae23ca..36a31625e29d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,24 +8,28 @@ Please start a discussion on the [Home repo issue tracker](https://github.com/as ## Bugs and feature requests? -Please log a new issue in the appropriate GitHub repo. Here are some of the most common repos: +For non-security related bugs please log a new issue in the appropriate GitHub repo. Here are some of the most common repos: * [DependencyInjection](https://github.com/aspnet/DependencyInjection) +* [Docs](https://github.com/aspnet/Docs) * [EntityFramework](https://github.com/aspnet/EntityFramework) * [Identity](https://github.com/aspnet/Identity) -* [KRuntime](https://github.com/aspnet/KRuntime) * [MVC](https://github.com/aspnet/Mvc) -* [SignalR-Server](https://github.com/aspnet/SignalR-Server) +* [Razor](https://github.com/aspnet/Razor) +* [Templates](https://github.com/aspnet/Templates) +* [Tooling](https://github.com/aspnet/Tooling) +* [SignalR](https://github.com/aspnet/SignalR) -The full repo list is [here](https://github.com/aspnet). +Or browse the full list of repos in the [aspnet](https://github.com/aspnet/) organization. +## Reporting security issues and bugs +Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/ff852094.aspx). ## Other discussions Our team members also monitor several other discussion forums: -* [ASP.NET vNext forum](http://forums.asp.net/1255.aspx/1?ASP+NET+vNext) -* [StackOverflow](http://stackoverflow.com/questions/tagged/asp.net-vnext) with the `asp.net-vnext` or `entity-framework-7` tag -* [JabbR chat room](https://jabbr.net/#/rooms/aspnetvnext) for real-time discussions with the community and the people who work on the project +* [ASP.NET Core forum](https://forums.asp.net/1255.aspx/1?ASP+NET+5) +* [Stack Overflow](https://stackoverflow.com/) with the [`asp.net-core`](https://stackoverflow.com/questions/tagged/asp.net-core), [`asp.net-core-mvc`](https://stackoverflow.com/questions/tagged/asp.net-core-mvc), or [`entity-framework-core`](https://stackoverflow.com/questions/tagged/entity-framework-core) tags. ## Filing issues @@ -37,21 +41,34 @@ Here are questions you can answer before you file a bug to make sure you're not 1. Did you read the [documentation](https://github.com/aspnet/home/wiki)? 2. Did you include the snippet of broken code in the issue? 3. What are the *EXACT* steps to reproduce this problem? -4. What package versions are you using (you can see these in the `project.json` file)? +4. What package versions are you using (you can see these in the `.csproj` file)? 5. What operating system are you using? 6. What version of IIS are you using? -GitHub supports [markdown](http://github.github.com/github-flavored-markdown/), so when filing bugs make sure you check the formatting before clicking submit. +GitHub supports [markdown](https://help.github.com/articles/github-flavored-markdown/), so when filing bugs make sure you check the formatting before clicking submit. ## Contributing code and content -You will need to sign a [Contributor License Agreement](https://cla.msopentech.com) before submitting your pull request. To complete the Contributor License Agreement (CLA), you will need to submit a request via the form and then electronically sign the Contributor License Agreement when you receive the email containing the link to the document. This needs to only be done once for any Microsoft Open Technologies OSS project. -Make sure you can build the code. Familiarize yourself with the project workflow and our coding conventions. If you don't know what a pull request is read this article: https://help.github.com/articles/using-pull-requests. +**Identifying the scale** -Before submitting a feature or substantial code contribution please discuss it with the team and ensure it follows the product roadmap. You might also read these two blogs posts on contributing code: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don't "Push" Your Pull Requests](http://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik. Note that all code submissions will be rigorously reviewed and tested by the ASP.NET and Entity Framework teams, and only those that meet an extremely high bar for both quality and design/roadmap appropriateness will be merged into the source. +If you would like to contribute to one of our repositories, first identify the scale of what you would like to contribute. If it is small (grammar/spelling or a bug fix) feel free to start working on a fix. If you are submitting a feature or substantial code contribution, please discuss it with the team and ensure it follows the product roadmap. You might also read these two blogs posts on contributing code: [Open Source Contribution Etiquette](http://tirania.org/blog/archive/2010/Dec-31.html) by Miguel de Icaza and [Don't "Push" Your Pull Requests](https://www.igvita.com/2011/12/19/dont-push-your-pull-requests/) by Ilya Grigorik. Note that all code submissions will be rigorously reviewed and tested by the ASP.NET and Entity Framework teams, and only those that meet an extremely high bar for both quality and design/roadmap appropriateness will be merged into the source. -Here's a few things you should always do when making changes to the code base: +**Obtaining the source code** + +If you are an outside contributer, please fork the ASP.NET repository you would like to contribute to your account. See the GitHub documentation for [forking a repo](https://help.github.com/articles/fork-a-repo/) if you have any questions about this. + +**Building our Repositories** + +As our repositories use the latest bits of our code, we have a custom build script to fetch and use them. Please go through [building our repositories from source](https://github.com/aspnet/Home/wiki/Building-from-source) to understand and fix any issues. + +**Submitting a pull request** + +You will need to sign a [Contributor License Agreement](https://cla2.dotnetfoundation.org/) before submitting your pull request. To complete the Contributor License Agreement (CLA), you will need to submit a request via the form and then electronically sign the Contributor License Agreement when you receive the email containing the link to the document. This needs to only be done once for any .NET Foundation OSS project. + +If you don't know what a pull request is read this article: https://help.github.com/articles/using-pull-requests. Make sure the respository can build and all tests pass. Familiarize yourself with the project workflow and our coding conventions. The coding, style, and general engineering guidelines are published on the [Engineering guidelines](https://github.com/aspnet/Home/wiki/Engineering-guidelines) page. + +Pull requests should all be done to the **dev** branch (not master). **Commit/Pull Request Format** @@ -60,7 +77,7 @@ Summary of the changes (Less than 80 chars) - Detail 1 - Detail 2 -#bugnumber (in this specific format) +Addresses #bugnumber (in this specific format) ``` **Tests** @@ -69,3 +86,7 @@ Summary of the changes (Less than 80 chars) - Tests only need to be present for issues that need to be verified by QA (e.g. not tasks) - If there is a scenario that is far too hard to test there does not need to be a test for it. - "Too hard" is determined by the team as a whole. + +**Feedback** + +Your pull request will now go through extensive checks by the subject matter experts on our team. Please be patient; we have hundreds of pull requests across all of our repositories. Update your pull request according to feedback until it is approved by one of the ASP.NET team members. After that, one of our team members will add the pull request to **dev**. diff --git a/LICENSE.txt b/LICENSE.txt index d85a1524adfa..a275bdeab78d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,12 +1,14 @@ -Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +Copyright (c) .NET Foundation and Contributors + +All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use -these files except in compliance with the License. You may obtain a copy of the +this file except in compliance with the License. You may obtain a copy of the License at -http://www.apache.org/licenses/LICENSE-2.0 + http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. +specific language governing permissions and limitations under the License. \ No newline at end of file diff --git a/NuGet.Config b/NuGet.Config deleted file mode 100644 index 600a375c7e4a..000000000000 --- a/NuGet.Config +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 470ffea53667..01dddd733b58 100644 --- a/README.md +++ b/README.md @@ -1,99 +1,75 @@ -# ASP.NET vNext Home -The Home repository is the starting point for people to learn about ASP.NET vNext. This repo contains samples and [documentation](https://github.com/aspnet/Home/wiki) to help folks get started and learn more about what's coming in ASP..NET vNext. +# ASP.NET Core +[![Join the chat at https://gitter.im/aspnet/Home](https://badges.gitter.im/aspnet/Home.svg)](https://gitter.im/aspnet/Home?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) -ASP.NET vNext is being actively developed by the ASP.NET team assigned to the Microsoft Open Tech Hub and in collaboration with a community of open source developers. Together we are dedicated to creating the best possible platform for web development. +This is the home page of the ASP.NET Core source code repositories and is intended for those contributing to ASP.NET Core or using bleeding edge nightly builds. -The samples provided in this repo are designed to show some of the features of the new framework and to provide a starting point for further exploration. The NuGet.config file in the repo points to a MyGet feed (https://www.myget.org/F/aspnetvnext/) that has all the packages being developed. This feed is updated with each preview release. To try out the latest bits under development use the dev feed instead (https://www.myget.org/F/aspnetvnext). +ASP.NET Core is a new open-source and cross-platform framework for building modern cloud based internet connected applications, such as web apps, IoT apps and mobile backends. ASP.NET Core apps can run on .NET Core or on the full .NET Framework. It was architected to provide an optimized development framework for apps that are deployed to the cloud or run on-premises. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions. You can develop and run your ASP.NET Core apps cross-platform on Windows, Mac and Linux. [Learn more about ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/). -## Minimum Requirements +ASP.NET Core 1.1 is now available! See the [release notes](https://github.com/aspnet/Home/releases/tag/1.1.0) for further details. -These are the current minimum requirements for the latest preview release. They do not necessarily represent what the final minimum requirements will be. +ASP.NET Core 2.0 is now available! See the [release notes](https://github.com/aspnet/Home/releases/tag/2.0.0) for further details and check our [releases](https://github.com/aspnet/home/releases) for the latest patch release. -#### Windows -* Windows 7 or Windows Server 2008 R2. -* .NET 4.5.1 for hosting in IIS +## Get Started -#### OS X/Linux - * Mono 3.4.1 or later (Note: On OS X use the Homebrew formula specified below to install the required version of Mono) - * bash or zsh and curl +Follow the [Getting Started](https://docs.microsoft.com/en-us/aspnet/core/getting-started) instructions in the [ASP.NET Core docs](https://docs.microsoft.com/en-us/aspnet/index). -## Getting Started +Also checkout the [.NET Homepage](https://www.microsoft.com/net) for released versions of .NET, getting started guides, and learning resources. -The easiest way to get started with ASP.NET vNext is to try out the latest preview of Visual Studio "14". You can find installation instructions and getting started documentation at http://www.asp.net/vnext. +## Builds -That said, you can also try out ASP.NET vNext with just a command-prompt and a text editor. The following instructions will walk you through getting your dev environment setup. +[![MyGet tenant](https://img.shields.io/dotnet.myget/aspnetcore-dev/v/Microsoft.AspNetCore.All.svg)]() -### Install the K Version Manager (KVM) +If you want to use the latest dev build then you need to: -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). You use the K Version Manager to install different versions of the ASP.NET vNext runtime and switch between them. +- Obtain the latest [build of the .NET Core SDK](https://github.com/dotnet/cli#installers-and-binaries) +- Add a NuGet.Config to your app with the following content: -#### Windows -To install KVM on Windows run the following command, which will download and run a script that installs KVM for the current user (requires admin privileges): -```powershell -@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/kvminstall.ps1'))" -``` -After the script has run open a new command prompt to start using KVM. + ```xml + + + + + + + + + ``` -#### OS X: + *NOTE: This NuGet.Config should be with your application unless you want nightly packages to potentially start being restored for other apps on the machine.* -To install KVM and the correct version of Mono on OS X using [Homebrew](http://brew.sh) follow the following steps: +- Change your applications dependencies to have a `*` to get the latest version (ex. `1.0.0-*`). - * Install [Homebrew](http://brew.sh) if it is not already installed. - * Run command `brew tap aspnet/k` to tap the ASP.NET vNext related git repositories. - * Run command `brew install kvm` to install KVM. This also automatically install the latest KRE package from https://www.myget.org/f/aspnetvnext/api/v2 feed. - * Run command `source kvm.sh` on your terminal if your terminal cannot understand kvm. +Prerelease tooling builds for Visual Studio are available from the [Tooling](https://github.com/aspnet/tooling/#pre-release-builds) repo. -#### Linux: -To install KVM on Linux run the following command: -``` -curl https://raw.githubusercontent.com/aspnet/Home/dev/kvminstall.sh | sh && source ~/.kre/kvm/kvm.sh -``` +## Community and roadmap -Note that on Linux you need to also install [Mono](http://mono-project.com) 3.4.1 or later. +To follow along with the development of ASP.NET Core: -### Install the K Runtime Environment (KRE) +- [Community Standup](http://live.asp.net): The community standup is held every week and streamed live to YouTube. You can view past standups in the linked playlist. +- [Roadmap](https://github.com/aspnet/Home/wiki/Roadmap): The schedule and milestone themes for ASP.NET Core. -Now that you have KVM setup you can install the latest version of the runtime by running the following command: ```kvm upgrade``` - -This command will download the specified version of the K Runtime Environment (KRE), and put it on your user profile ready to use. You are now ready to start using ASP.NET vNext! +## Repos and projects -# Samples +These are some of the most common repos: -The samples in this repo are basic starting points for you to experiment with. +* [DependencyInjection](https://github.com/aspnet/DependencyInjection) - basic dependency injection infrastructure and default implementation +* [Docs](https://github.com/aspnet/Docs) - documentation sources for https://docs.microsoft.com/en-us/aspnet/core/ +* [EntityFrameworkCore](https://github.com/aspnet/EntityFrameworkCore) - data access technology +* [Identity](https://github.com/aspnet/Identity) - users and membership system +* [MVC](https://github.com/aspnet/Mvc) - MVC framework for web apps and services +* [Razor](https://github.com/aspnet/Razor) - template language and syntax for CSHTML files +* [SignalR](https://github.com/aspnet/SignalR) - library to add real-time web functionality +* [Templates](https://github.com/aspnet/Templates) - project templates for Visual Studio +* [Tooling](https://github.com/aspnet/Tooling) - Visual Studio tooling, editors, and dialogs -+ [ConsoleApp](https://github.com/aspnet/Home/tree/dev/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/dev/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. -+ [HelloMvc](https://github.com/aspnet/Home/tree/dev/samples/HelloMvc). 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. -+ [MVC Music Store](https://github.com/aspnet/MusicStore) and [BugTracker](https://github.com/aspnet/BugTracker) are application samples that are both being ported to ASP.NET vNext. Each of these samples have their own separate repositories that you can look at. +## NuGet feeds and branches -### Running the samples - -1. Clone the Home repository -2. Change directory to the folder of the sample you want to run -3. Run ```kpm restore``` to restore the packages required by that sample. -4. You should see a bunch of output as all the dependencies of the app are downloaded from MyGet. -5. Run the sample using the appropriate K command: - - For the console app run ```k run```. - - For the web apps run ```k web``` on Windows or ```k kestrel``` on Mono. -6. You should see the output of the console app or a message that says the site is now started. -7. You can navigate to the web apps in a browser by going to "http://localhost:5001" or "http://localhost:5004" if running on Mono. - -### Switching to Core CLR - -By default when running ASP.NET vNext applications on the Windows platform you are running on the full .NET Framework. You can switch to use the new Cloud Optimized runtime, or Core CLR, using the KVM command. - -1. Run ```kvm upgrade -runtime CoreCLR``` This command gets the latest Core CLR version of the k runtime and sets it as your default. The `-runtime CoreCLR` switch tells it to use Core CLR. You can use `-r CLR` to target desktop again. -2. Run ```k web``` to run on WebListener. -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 the full desktop .NET Framework but now as a fully self-contained app with true side-by-side versioning support. - -**NOTE: There are many APIs from the .NET Framework that are not yet available when running on Core CLR. This set should get smaller and smaller as time goes on.** - -**NOTE: There is no Core CLR currently available on OSX/Linux. There is only a single platform (mono45) and a single architecture (x86).** +See the [NuGet feeds](https://github.com/aspnet/Home/wiki/NuGet-feeds) wiki page. # Feedback -Check out the [contributing](https://github.com/aspnet/Home/blob/dev/CONTRIBUTING.md) page to see the best places to log issues and start discussions. +Check out the [contributing](CONTRIBUTING.md) page to see the best places to log issues and start discussions. + diff --git a/kvm.cmd b/kvm.cmd deleted file mode 100644 index 79909f761909..000000000000 --- a/kvm.cmd +++ /dev/null @@ -1,8 +0,0 @@ -@Echo off - -PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0kvm.ps1' %*" - -IF EXIST "%USERPROFILE%\.kre\run-once.cmd" ( - CALL "%USERPROFILE%\.kre\run-once.cmd" - DEL "%USERPROFILE%\.kre\run-once.cmd" -) diff --git a/kvm.ps1 b/kvm.ps1 deleted file mode 100644 index 2367bebffe71..000000000000 --- a/kvm.ps1 +++ /dev/null @@ -1,745 +0,0 @@ -param( - [parameter(Position=0)] - [string] $command, - [string] $proxy, - [switch] $verbosity = $false, - [alias("g")][switch] $global = $false, - [alias("p")][switch] $persistent = $false, - [alias("f")][switch] $force = $false, - [alias("r")][string] $runtime, - [switch] $x86 = $false, - [switch] $amd64 = $false, - #deprecated - [switch] $x64 = $false, - #deprecated - [switch] $svr50 = $false, - #deprecated - [switch] $svrc50 = $false, - [alias("w")][switch] $wait = $false, - [alias("a")] - [string] $alias = $null, - [parameter(Position=1, ValueFromRemainingArguments=$true)] - [string[]]$args=@() -) - -$selectedArch=$null; -$defaultArch="x86" -$selectedRuntime=$null -$defaultRuntime="CLR" -$userKrePath = $env:USERPROFILE + "\.kre" -$userKrePackages = $userKrePath + "\packages" -$globalKrePath = $env:ProgramFiles + "\KRE" -$globalKrePackages = $globalKrePath + "\packages" -$feed = $env:KRE_NUGET_API_URL - -function String-IsEmptyOrWhitespace([string]$str) { - return [string]::IsNullOrEmpty($str) -or $str.Trim().length -eq 0 -} - -if (!$feed) -{ - $feed = "https://www.myget.org/F/aspnetvnext/api/v2"; -} - -$scriptPath = $myInvocation.MyCommand.Definition - -function Kvm-Help { -@" -K Runtime Environment Version Manager - Build 10017 - -USAGE: kvm [options] - -kvm upgrade [-x86][-amd64] [-r|-runtime CLR|CoreCLR] [-g|-global] [-f|-force] [-proxy
] - install latest KRE from feed - set 'default' alias to installed version - add KRE bin to user PATH environment variable - -g|-global install to machine-wide location - -f|-force upgrade even if latest is already installed - -proxy
use given address as proxy when accessing remote server - -kvm install |||latest [-x86][-amd64] [-r|-runtime CLR|CoreCLR] [-a|-alias ] [-g|-global] [-f|-force] - | install requested KRE from feed - install requested KRE from package on local filesystem - latest install latest KRE from feed - add KRE bin to path of current command line - -p|-persistent add KRE bin to PATH environment variables persistently - -a|-alias set alias for requested KRE on install - -g|-global install to machine-wide location - -f|-force install even if specified version is already installed - -kvm use ||none [-x86][-amd64] [-r|-runtime CLR|CoreCLR] [-p|-persistent] [-g|-global] - | add KRE bin to path of current command line - none remove KRE bin from path of current command line - -p|-persistent add KRE bin to PATH environment variables persistently - -g|-global combined with -p to change machine PATH instead of user PATH - -kvm list - list KRE versions installed - -kvm alias - list KRE aliases which have been defined - -kvm alias - display value of the specified alias - -kvm alias | [-x86][-amd64] [-r|-runtime CLR|CoreCLR] - The name of the alias to set - | The KRE version to set the alias to. Alternatively use the version of the specified alias - -kvm unalias - remove the specified alias - -"@ -replace "`n","`r`n" | Write-Host -} - -function Kvm-Global-Setup { - $kvmBinPath = "$userKrePath\bin" - - If (Needs-Elevation) - { - $arguments = "-ExecutionPolicy unrestricted & '$scriptPath' setup -global -wait" - Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments -Wait - Write-Host "Adding $kvmBinPath to process PATH" - Set-Path (Change-Path $env:Path $kvmBinPath ($kvmBinPath)) - Write-Host "Adding $globalKrePath;%USERPROFILE%\.kre to process KRE_HOME" - $envKreHome = $env:KRE_HOME - $envKreHome = Change-Path $envKreHome "%USERPROFILE%\.kre" ("%USERPROFILE%\.kre") - $envKreHome = Change-Path $envKreHome $globalKrePath ($globalKrePath) - $env:KRE_HOME = $envKreHome - Write-Host "Setup complete" - break - } - - $scriptFolder = [System.IO.Path]::GetDirectoryName($scriptPath) - - Write-Host "Copying file $kvmBinPath\kvm.ps1" - md $kvmBinPath -Force | Out-Null - copy "$scriptFolder\kvm.ps1" "$kvmBinPath\kvm.ps1" - - Write-Host "Copying file $kvmBinPath\kvm.cmd" - copy "$scriptFolder\kvm.cmd" "$kvmBinPath\kvm.cmd" - - Write-Host "Adding $kvmBinPath to process PATH" - Set-Path (Change-Path $env:Path $kvmBinPath ($kvmBinPath)) - - Write-Host "Adding $kvmBinPath to user PATH" - $userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User) - $userPath = Change-Path $userPath $kvmBinPath ($kvmBinPath) - [Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User) - - Write-Host "Adding $globalKrePath;%USERPROFILE%\.kre to process KRE_HOME" - $envKreHome = $env:KRE_HOME - $envKreHome = Change-Path $envKreHome "%USERPROFILE%\.kre" ("%USERPROFILE%\.kre") - $envKreHome = Change-Path $envKreHome $globalKrePath ($globalKrePath) - $env:KRE_HOME = $envKreHome - - Write-Host "Adding $globalKrePath;%USERPROFILE%\.kre to machine KRE_HOME" - $machineKreHome = [Environment]::GetEnvironmentVariable("KRE_HOME", [System.EnvironmentVariableTarget]::Machine) - $machineKreHome = Change-Path $machineKreHome "%USERPROFILE%\.kre" ("%USERPROFILE%\.kre") - $machineKreHome = Change-Path $machineKreHome $globalKrePath ($globalKrePath) - [Environment]::SetEnvironmentVariable("KRE_HOME", $machineKreHome, [System.EnvironmentVariableTarget]::Machine) -} - -function Kvm-Global-Upgrade { - $persistent = $true - $alias="default" - $versionOrAlias = Kvm-Find-Latest $selectedRuntime $selectedArch - If (Needs-Elevation) { - $arguments = "-ExecutionPolicy unrestricted & '$scriptPath' install '$versionOrAlias' -global $(Requested-Switches) -wait" - Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments -Wait - Kvm-Set-Global-Process-Path $versionOrAlias - break - } - Kvm-Install $versionOrAlias $true -} - -function Kvm-Upgrade { - $persistent = $true - $alias="default" - Kvm-Install "latest" $false -} - -function Add-Proxy-If-Specified { -param( - [System.Net.WebClient] $wc -) - if (!$proxy) { - $proxy = $env:http_proxy - } - if ($proxy) { - $wp = New-Object System.Net.WebProxy($proxy) - $pb = New-Object UriBuilder($proxy) - if (!$pb.UserName) { - $wp.Credentials = [System.Net.CredentialCache]::DefaultCredentials - } else { - $wp.Credentials = New-Object System.Net.NetworkCredential($pb.UserName, $pb.Password) - } - $wc.Proxy = $wp - } -} - -function Kvm-Find-Latest { -param( - [string] $platform, - [string] $architecture -) - Write-Host "Determining latest version" - - $url = "$feed/GetUpdates()?packageIds=%27KRE-$platform-$architecture%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false" - - $wc = New-Object System.Net.WebClient - $wc.Credentials = new-object System.Net.NetworkCredential("aspnetreadonly", "4d8a2d9c-7b80-4162-9978-47e918c9658c") - Add-Proxy-If-Specified($wc) - [xml]$xml = $wc.DownloadString($url) - - $version = Select-Xml "//d:Version" -Namespace @{d='http://schemas.microsoft.com/ado/2007/08/dataservices'} $xml - - if (String-IsEmptyOrWhitespace($version)) { - throw "There are no packages for platform '$platform', architecture '$architecture' in the feed '$feed'" - } - - return $version -} - -function Do-Kvm-Download { -param( - [string] $kreFullName, - [string] $packagesFolder -) - $parts = $kreFullName.Split(".", 2) - - $url = "$feed/package/" + $parts[0] + "/" + $parts[1] - $kreFolder = Join-Path $packagesFolder $kreFullName - $kreFile = Join-Path $kreFolder "$kreFullName.nupkg" - - If (Test-Path $kreFolder) { - if($force) - { - rm $kreFolder -Recurse -Force - } else { - Write-Host "$kreFullName already installed." - return; - } - } - - Write-Host "Downloading" $kreFullName "from $feed" - - #Downloading to temp location - $kreTempDownload = Join-Path $packagesFolder "temp" - $tempKreFile = Join-Path $kreTempDownload "$kreFullName.nupkg" - - if(Test-Path $kreTempDownload) { - del "$kreTempDownload\*" -recurse - } else { - md $kreTempDownload -Force | Out-Null - } - - $wc = New-Object System.Net.WebClient - $wc.Credentials = new-object System.Net.NetworkCredential("aspnetreadonly", "4d8a2d9c-7b80-4162-9978-47e918c9658c") - Add-Proxy-If-Specified($wc) - $wc.DownloadFile($url, $tempKreFile) - - Do-Kvm-Unpack $tempKreFile $kreTempDownload - - md $kreFolder -Force | Out-Null - Write-Host "Installing to $kreFolder" - mv "$kreTempDownload\*" $kreFolder - Remove-Item "$kreTempDownload" -Force | Out-Null -} - -function Do-Kvm-Unpack { -param( - [string] $kreFile, - [string] $kreFolder -) - Write-Host "Unpacking to" $kreFolder - try { - #Shell will not recognize nupkg as a zip and throw, so rename it to zip - $kreZip = [System.IO.Path]::ChangeExtension($kreFile, "zip") - Rename-Item $kreFile $kreZip - #Use the shell to uncompress the nupkg - $shell_app=new-object -com shell.application - $zip_file = $shell_app.namespace($kreZip) - $destination = $shell_app.namespace($kreFolder) - $destination.Copyhere($zip_file.items(), 0x14) #0x4 = don't show UI, 0x10 = overwrite files - } - finally { - #make it a nupkg again - Rename-Item $kreZip $kreFile - } - - If (Test-Path ($kreFolder + "\[Content_Types].xml")) { - Remove-Item ($kreFolder + "\[Content_Types].xml") - } - If (Test-Path ($kreFolder + "\_rels\")) { - Remove-Item ($kreFolder + "\_rels\") -Force -Recurse - } - If (Test-Path ($kreFolder + "\package\")) { - Remove-Item ($kreFolder + "\package\") -Force -Recurse - } -} - -function Kvm-Install { -param( - [string] $versionOrAlias, - [boolean] $isGlobal -) - if ($versionOrAlias -eq "latest") { - $versionOrAlias = Kvm-Find-Latest (Requested-Platform $defaultRuntime) (Requested-Architecture $defaultArch) - } - - if ($versionOrAlias.EndsWith(".nupkg")) { - $kreFullName = [System.IO.Path]::GetFileNameWithoutExtension($versionOrAlias) - } else { - $kreFullName = Requested-VersionOrAlias $versionOrAlias - } - - if ($isGlobal) { - if (Needs-Elevation) { - $arguments = "-ExecutionPolicy unrestricted & '$scriptPath' install '$versionOrAlias' -global $(Requested-Switches) -wait" - Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments -Wait - Kvm-Set-Global-Process-Path $versionOrAlias - break - } - $packageFolder = $globalKrePackages - } else { - $packageFolder = $userKrePackages - } - - if ($versionOrAlias.EndsWith(".nupkg")) { - Set-Variable -Name "selectedArch" -Value (Package-Arch $kreFullName) -Scope Script - Set-Variable -Name "selectedRuntime" -Value (Package-Platform $kreFullName) -Scope Script - - $kreFolder = "$packageFolder\$kreFullName" - $folderExists = Test-Path $kreFolder - - if ($folderExists -and $force) { - del $kreFolder -Recurse -Force - $folderExists = $false; - } - - if ($folderExists) { - Write-Host "Target folder '$kreFolder' already exists" - } else { - $tempUnpackFolder = Join-Path $packageFolder "temp" - $tempKreFile = Join-Path $tempUnpackFolder "$kreFullName.nupkg" - - if(Test-Path $tempUnpackFolder) { - del "$tempUnpackFolder\*" -recurse - } else { - md $tempUnpackFolder -Force | Out-Null - } - copy $versionOrAlias $tempKreFile - - Do-Kvm-Unpack $tempKreFile $tempUnpackFolder - md $kreFolder -Force | Out-Null - Write-Host "Installing to $kreFolder" - mv "$tempUnpackFolder\*" $kreFolder - Remove-Item "$tempUnpackFolder" -Force | Out-Null - } - - $packageVersion = Package-Version $kreFullName - - Kvm-Use $packageVersion - if (!$(String-IsEmptyOrWhitespace($alias))) { - Kvm-Alias-Set $alias $packageVersion - } - } - else - { - Do-Kvm-Download $kreFullName $packageFolder - Kvm-Use $versionOrAlias - if (!$(String-IsEmptyOrWhitespace($alias))) { - Kvm-Alias-Set "$alias" $versionOrAlias - } - } -} - -function Kvm-List { - $kreHome = $env:KRE_HOME - if (!$kreHome) { - $kreHome = "$globalKrePath;$userKrePath" - } - - md ($userKrePath + "\alias\") -Force | Out-Null - $aliases = Get-ChildItem ($userKrePath + "\alias\") | Select @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }} - - $items = @() - foreach($portion in $kreHome.Split(';')) { - $path = [System.Environment]::ExpandEnvironmentVariables($portion) - if (Test-Path("$path\packages")) { - $items += Get-ChildItem ("$path\packages\KRE-*") | List-Parts $aliases - } - } - - $items | Sort-Object Version, Runtime, Architecture, Alias | Format-Table -AutoSize -Property @{name="Active";expression={$_.Active};alignment="center"}, "Version", "Runtime", "Architecture", "Location", "Alias" -} - -filter List-Parts { - param($aliases) - - $hasBin = Test-Path($_.FullName+"\bin") - if (!$hasBin) { - return - } - $active = $false - foreach($portion in $env:Path.Split(';')) { - if ($portion.StartsWith($_.FullName)) { - $active = $true - } - } - - $fullAlias="" - $delim="" - - foreach($alias in $aliases){ - if($_.Name.Split('\', 2).Contains($alias.Name)){ - $fullAlias += $delim + $alias.Alias - $delim = ", " - } - } - - $parts1 = $_.Name.Split('.', 2) - $parts2 = $parts1[0].Split('-', 3) - return New-Object PSObject -Property @{ - Active = if ($active) { "*" } else { "" } - Version = $parts1[1] - Runtime = $parts2[1] - Architecture = $parts2[2] - Location = $_.Parent.FullName - Alias = $fullAlias - } -} - -function Kvm-Global-Use { -param( - [string] $versionOrAlias -) - If (Needs-Elevation) { - $arguments = "-ExecutionPolicy unrestricted & '$scriptPath' use '$versionOrAlias' -global $(Requested-Switches) -wait" - Start-Process "$psHome\powershell.exe" -Verb runAs -ArgumentList $arguments -Wait - Kvm-Set-Global-Process-Path $versionOrAlias - break - } - - Kvm-Set-Global-Process-Path "$versionOrAlias" - - if ($versionOrAlias -eq "none") { - if ($persistent) { - Write-Host "Removing KRE from machine PATH" - $machinePath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) - $machinePath = Change-Path $machinePath "" ($globalKrePackages, $userKrePackages) - [Environment]::SetEnvironmentVariable("Path", $machinePath, [System.EnvironmentVariableTarget]::Machine) - } - return; - } - - $kreFullName = Requested-VersionOrAlias "$versionOrAlias" - $kreBin = Locate-KreBinFromFullName $kreFullName - if ($kreBin -eq $null) { - Write-Host "Cannot find $kreFullName, do you need to run 'kvm install $versionOrAlias'?" - return - } - - if ($persistent) { - Write-Host "Adding $kreBin to machine PATH" - $machinePath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::Machine) - $machinePath = Change-Path $machinePath $kreBin ($globalKrePackages, $userKrePackages) - [Environment]::SetEnvironmentVariable("Path", $machinePath, [System.EnvironmentVariableTarget]::Machine) - } -} - -function Kvm-Set-Global-Process-Path { -param( - [string] $versionOrAlias -) - if ($versionOrAlias -eq "none") { - Write-Host "Removing KRE from process PATH" - Set-Path (Change-Path $env:Path "" ($globalKrePackages, $userKrePackages)) - return - } - - $kreFullName = Requested-VersionOrAlias $versionOrAlias - $kreBin = Locate-KreBinFromFullName $kreFullName - if ($kreBin -eq $null) { - Write-Host "Cannot find $kreFullName, do you need to run 'kvm install $versionOrAlias'?" - return - } - - Write-Host "Adding" $kreBin "to process PATH" - Set-Path (Change-Path $env:Path $kreBin ($globalKrePackages, $userKrePackages)) -} - -function Kvm-Use { -param( - [string] $versionOrAlias -) - if ($versionOrAlias -eq "none") { - Write-Host "Removing KRE from process PATH" - Set-Path (Change-Path $env:Path "" ($globalKrePackages, $userKrePackages)) - - if ($persistent) { - Write-Host "Removing KRE from user PATH" - $userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User) - $userPath = Change-Path $userPath "" ($globalKrePackages, $userKrePackages) - [Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User) - } - return; - } - - $kreFullName = Requested-VersionOrAlias $versionOrAlias - - $kreBin = Locate-KreBinFromFullName $kreFullName - if ($kreBin -eq $null) { - Write-Host "Cannot find $kreFullName, do you need to run 'kvm install $versionOrAlias'?" - return - } - - Write-Host "Adding" $kreBin "to process PATH" - Set-Path (Change-Path $env:Path $kreBin ($globalKrePackages, $userKrePackages)) - - if ($persistent) { - Write-Host "Adding $kreBin to user PATH" - $userPath = [Environment]::GetEnvironmentVariable("Path", [System.EnvironmentVariableTarget]::User) - $userPath = Change-Path $userPath $kreBin ($globalKrePackages, $userKrePackages) - [Environment]::SetEnvironmentVariable("Path", $userPath, [System.EnvironmentVariableTarget]::User) - } -} - -function Kvm-Alias-List { - md ($userKrePath + "\alias\") -Force | Out-Null - - Get-ChildItem ($userKrePath + "\alias\") | Select @{label='Alias';expression={$_.BaseName}}, @{label='Name';expression={Get-Content $_.FullName }} | Format-Table -AutoSize -} - -function Kvm-Alias-Get { -param( - [string] $name -) - md ($userKrePath + "\alias\") -Force | Out-Null - $aliasFilePath=$userKrePath + "\alias\" + $name + ".txt" - if (!(Test-Path $aliasFilePath)) { - Write-Host "Alias '$name' does not exist" - } else { - Write-Host "Alias '$name' is set to" (Get-Content ($userKrePath + "\alias\" + $name + ".txt")) - } -} - -function Kvm-Alias-Set { -param( - [string] $name, - [string] $value -) - $kreFullName = Requested-VersionOrAlias $value - $aliasFilePath = $userKrePath + "\alias\" + $name + ".txt" - $action = if (Test-Path $aliasFilePath) { "Updating" } else { "Setting" } - Write-Host "$action alias '$name' to '$kreFullName'" - md ($userKrePath + "\alias\") -Force | Out-Null - $kreFullName | Out-File ($aliasFilePath) ascii -} - -function Kvm-Unalias { -param( - [string] $name -) - $aliasPath=$userKrePath + "\alias\" + $name + ".txt" - if (Test-Path -literalPath "$aliasPath") { - Write-Host "Removing alias $name" - Remove-Item -literalPath $aliasPath - } else { - Write-Host "Cannot remove alias, '$name' is not a valid alias name" - } -} - -function Locate-KreBinFromFullName() { -param( - [string] $kreFullName -) - $kreHome = $env:KRE_HOME - if (!$kreHome) { - $kreHome = "$globalKrePath;$userKrePath" - } - foreach($portion in $kreHome.Split(';')) { - $path = [System.Environment]::ExpandEnvironmentVariables($portion) - $kreBin = "$path\packages\$kreFullName\bin" - if (Test-Path "$kreBin") { - return $kreBin - } - } - return $null -} - -function Package-Version() { -param( - [string] $kreFullName -) - return $kreFullName -replace '[^.]*.(.*)', '$1' -} - -function Package-Platform() { -param( - [string] $kreFullName -) - return $kreFullName -replace 'KRE-([^-]*).*', '$1' -} - -function Package-Arch() { -param( - [string] $kreFullName -) - return $kreFullName -replace 'KRE-[^-]*-([^.]*).*', '$1' -} - - -function Requested-VersionOrAlias() { -param( - [string] $versionOrAlias -) - If (Test-Path ($userKrePath + "\alias\" + $versionOrAlias + ".txt")) { - $aliasValue = Get-Content ($userKrePath + "\alias\" + $versionOrAlias + ".txt") - $parts = $aliasValue.Split('.', 2) - $pkgVersion = $parts[1] - $parts =$parts[0].Split('-', 3) - $pkgPlatform = Requested-Platform $parts[1] - $pkgArchitecture = Requested-Architecture $parts[2] - } else { - $pkgVersion = $versionOrAlias - $pkgPlatform = Requested-Platform $defaultRuntime - $pkgArchitecture = Requested-Architecture $defaultArch - } - return "KRE-" + $pkgPlatform + "-" + $pkgArchitecture + "." + $pkgVersion -} - -function Requested-Platform() { -param( - [string] $default -) - if (!(String-IsEmptyOrWhitespace($selectedRuntime))) {return $selectedRuntime} - return $default -} - -function Requested-Architecture() { -param( - [string] $default -) - if (!(String-IsEmptyOrWhitespace($selectedArch))) {return $selectedArch} - return $default -} - -function Change-Path() { -param( - [string] $existingPaths, - [string] $prependPath, - [string[]] $removePaths -) - $newPath = $prependPath - foreach($portion in $existingPaths.Split(';')) { - $skip = $portion -eq "" - foreach($removePath in $removePaths) { - if ($portion.StartsWith($removePath)) { - $skip = $true - } - } - if (!$skip) { - $newPath = $newPath + ";" + $portion - } - } - return $newPath -} - -function Set-Path() { -param( - [string] $newPath -) - md $userKrePath -Force | Out-Null - $env:Path = $newPath -@" -SET "PATH=$newPath" -"@ | Out-File ($userKrePath + "\run-once.cmd") ascii -} - -function Needs-Elevation() { - $user = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() - $elevated = $user.IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") - return -NOT $elevated -} - -function Requested-Switches() { - $arguments = "" - if ($x86) {$arguments = "$arguments -x86"} - if ($amd64) {$arguments = "$arguments -amd64"} - #deprecated - if ($x64) {$arguments = "$arguments -x64"} - if ($selectedRuntime) {$arguments = "$arguments -runtime $selectedRuntime"} - if ($persistent) {$arguments = "$arguments -persistent"} - if ($force) {$arguments = "$arguments -force"} - if (!$(String-IsEmptyOrWhitespace($alias))) {$arguments = "$arguments -alias '$alias'"} - return $arguments -} - -function Validate-And-Santitise-Switches() -{ - if ($svr50 -and $runtime) {throw "You cannot select both the -runtime switch and the -svr50 runtimes"} - if ($svrc50 -and $runtime) {throw "You cannot select both the -runtime switch and the -svrc50 runtimes"} - if ($x86 -and $amd64) {throw "You cannot select both x86 and amd64 architectures"} - if ($x86 -and $x64) {throw "You cannot select both x86 and x64 architectures"} - if ($x64 -and $amd64) {throw "You cannot select both x64 and amd64 architectures"} - - if ($runtime) { - $validRuntimes = "CoreCLR", "CLR", "svr50", "svrc50" - $match = $validRuntimes | ? { $_ -like $runtime } | Select -First 1 - if (!$match) {throw "'$runtime' is not a valid runtime"} - Set-Variable -Name "selectedRuntime" -Value $match -Scope Script - } elseif ($svr50) { - Write-Host "Warning: -svr50 is deprecated, use -runtime CLR for new packages." - Set-Variable -Name "selectedRuntime" -Value "svr50" -Scope Script - } elseif ($svrc50) { - Write-Host "Warning: -svrc50 is deprecated, use -runtime CoreCLR for new packages." - Set-Variable -Name "selectedRuntime" -Value "svrc50" -Scope Script - } - - if ($x64) { - Write-Host "Warning: -x64 is deprecated, use -amd64 for new packages." - Set-Variable -Name "selectedArch" -Value "x64" -Scope Script - } elseif ($amd64) { - Set-Variable -Name "selectedArch" -Value "amd64" -Scope Script - } elseif ($x86) { - Set-Variable -Name "selectedArch" -Value "x86" -Scope Script - } -} - -try { - Validate-And-Santitise-Switches - if ($global) { - switch -wildcard ($command + " " + $args.Count) { - "setup 0" {Kvm-Global-Setup} - "upgrade 0" {Kvm-Global-Upgrade} - "install 1" {Kvm-Install $args[0] $true} - "use 1" {Kvm-Global-Use $args[0]} - default {throw "Unknown command, or global switch not supported"}; - } - } else { - switch -wildcard ($command + " " + $args.Count) { - "setup 0" {Kvm-Global-Setup} - "upgrade 0" {Kvm-Upgrade} - "install 1" {Kvm-Install $args[0] $false} - "list 0" {Kvm-List} - "use 1" {Kvm-Use $args[0]} - "alias 0" {Kvm-Alias-List} - "alias 1" {Kvm-Alias-Get $args[0]} - "alias 2" {Kvm-Alias-Set $args[0] $args[1]} - "unalias 1" {Kvm-Unalias $args[0]} - "help 0" {Kvm-Help} - " 0" {Kvm-Help} - default {throw "Unknown command"}; - } - } -} -catch { - Write-Host $_ -ForegroundColor Red ; - Write-Host "Type 'kvm help' for help on how to use kvm." -} -if ($wait) { - Write-Host "Press any key to continue ..." - $x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown,AllowCtrlC") -} diff --git a/kvm.sh b/kvm.sh deleted file mode 100644 index c3a222cee10b..000000000000 --- a/kvm.sh +++ /dev/null @@ -1,400 +0,0 @@ -# kvm.sh -# Source this file from your .bash-profile or script to use -_kvm_has() { - type "$1" > /dev/null 2>&1 - return $? -} - -if _kvm_has "unsetopt"; then - unsetopt nomatch 2>/dev/null -fi - -if [ -z "$KRE_USER_HOME" ]; then - eval KRE_USER_HOME=~/.kre -fi - -KRE_USER_PACKAGES="$KRE_USER_HOME/packages" -if [ -z "$KRE_FEED" ]; then - KRE_FEED="https://www.myget.org/F/aspnetvnext/api/v2" -fi - -_kvm_find_latest() { - local platform="Mono" - - if ! _kvm_has "curl"; then - echo 'KVM Needs curl to proceed.' >&2; - return 1 - fi - - local url="$KRE_FEED/GetUpdates()?packageIds=%27KRE-$platform%27&versions=%270.0%27&includePrerelease=true&includeAllVersions=false" - xml="$(curl $url 2>/dev/null)" - echo $xml | grep \<[a-zA-Z]:Version\>* >> /dev/null || return 1 - version="$(echo $xml | sed 's/.*<[a-zA-Z]:Version>\([^<]*\).*/\1/')" - echo $version -} - -_kvm_strip_path() { - echo "$1" | sed -e "s#$KRE_USER_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$KRE_USER_PACKAGES/[^/]*$2[^:]*##g" -e "s#$KRE_USER_PACKAGES/[^/]*$2[^:]*##g" -} - -_kvm_prepend_path() { - if [ -z "$1" ]; then - echo "$2" - else - echo "$2:$1" - fi -} - -_kvm_package_version() { - local kreFullName="$1" - echo "$kreFullName" | sed "s/[^.]*.\(.*\)/\1/" -} - -_kvm_package_name() { - local kreFullName="$1" - echo "$kreFullName" | sed "s/\([^.]*\).*/\1/" -} - -_kvm_package_runtime() { - local kreFullName="$1" - echo "$kreFullName" | sed "s/KRE-\([^.-]*\).*/\1/" -} - -_kvm_download() { - local kreFullName="$1" - local kreFolder="$2" - - local pkgName=$(_kvm_package_name "$kreFullName") - local pkgVersion=$(_kvm_package_version "$kreFullName") - local url="$KRE_FEED/package/$pkgName/$pkgVersion" - local kreFile="$kreFolder/$kreFullName.nupkg" - - if [ -e "$kreFolder" ]; then - echo "$kreFullName already installed." - return 0 - fi - - echo "Downloading $kreFullName from $KRE_FEED" - - if ! _kvm_has "curl"; then - echo "KVM Needs curl to proceed." >&2; - return 1 - fi - - mkdir -p "$kreFolder" > /dev/null 2>&1 - - local httpResult=$(curl -L -D - -u aspnetreadonly:4d8a2d9c-7b80-4162-9978-47e918c9658c "$url" -o "$kreFile" 2>/dev/null | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/") - - [[ $httpResult == "404" ]] && echo "$kreFullName was not found in repository $KRE_FEED" && return 1 - [[ $httpResult != "302" && $httpResult != "200" ]] && echo "HTTP Error $httpResult fetching $kreFullName from $KRE_FEED" && return 1 - - _kvm_unpack $kreFile $kreFolder - return $? -} - -_kvm_unpack() { - local kreFile="$1" - local kreFolder="$2" - - echo "Installing to $kreFolder" - - if ! _kvm_has "unzip"; then - echo "KVM Needs unzip to proceed." >&2; - return 1 - fi - - unzip $kreFile -d $kreFolder > /dev/null 2>&1 - - [ -e "$kreFolder/[Content_Types].xml" ] && rm "$kreFolder/[Content_Types].xml" - - [ -e "$kreFolder/_rels/" ] && rm -rf "$kreFolder/_rels/" - - [ -e "$kreFolder/package/" ] && rm -rf "$kreFolder/_package/" - - #Set shell commands as executable - find "$kreFolder/bin/" -type f \ - -exec sh -c "head -c 11 {} | grep '/bin/bash' > /dev/null" \; -print | xargs chmod 775 -} - -_kvm_requested_version_or_alias() { - local versionOrAlias="$1" - - if [ -e "$KRE_USER_HOME/alias/$versionOrAlias.alias" ]; then - local kreFullName=$(cat "$KRE_USER_HOME/alias/$versionOrAlias.alias") - local pkgName=$(echo $kreFullName | sed "s/\([^.]*\).*/\1/") - local pkgVersion=$(echo $kreFullName | sed "s/[^.]*.\(.*\)/\1/") - local pkgPlatform=$(echo "$pkgName" | sed "s/KRE-\([^.-]*\).*/\1/") - else - local pkgVersion=$versionOrAlias - local pkgPlatform="Mono" - fi - - echo "KRE-$pkgPlatform.$pkgVersion" -} - -# This will be more relevant if we support global installs -_kvm_locate_kre_bin_from_full_name() { - local kreFullName=$1 - [ -e "$KRE_USER_PACKAGES/$kreFullName/bin" ] && echo "$KRE_USER_PACKAGES/$kreFullName/bin" && return -} - -kvm() -{ - if [ $# -lt 1 ]; then - kvm help - return - fi - - case $1 in - "help" ) - echo "" - echo "K Runtime Environment Version Manager - Build 10017" - echo "" - echo "USAGE: kvm [options]" - echo "" - echo "kvm upgrade" - echo "install latest KRE from feed" - echo "add KRE bin to path of current command line" - echo "set installed version as default" - echo "" - echo "kvm install |||latest [-a|-alias ] [-p -persistent]" - echo "| install requested KRE from feed" - echo " install requested KRE from local package on filesystem" - echo "latest install latest version of KRE from feed" - echo "-a|-alias set alias for requested KRE on install" - echo "-p -persistent set installed version as default" - echo "add KRE bin to path of current command line" - echo "" - echo "kvm use ||none [-p -persistent]" - echo "| add KRE bin to path of current command line " - echo "none remove KRE bin from path of current command line" - echo "-p -persistent set selected version as default" - echo "" - echo "kvm list" - echo "list KRE versions installed " - echo "" - echo "kvm alias" - echo "list KRE aliases which have been defined" - echo "" - echo "kvm alias " - echo "display value of the specified alias" - echo "" - echo "kvm alias " - echo " The name of the alias to set" - echo "| The KRE version to set the alias to. Alternatively use the version of the specified alias" - echo "" - echo "kvm unalias " - echo "remove the specified alias" - echo "" - ;; - - "upgrade" ) - [ $# -ne 1 ] && kvm help && return - kvm install latest -p - ;; - - "install" ) - [ $# -lt 2 ] && kvm help && return - shift - local persistant= - local versionOrAlias= - local alias= - while [ $# -ne 0 ] - do - if [[ $1 == "-p" || $1 == "-persistant" ]]; then - local persistent="-p" - elif [[ $1 == "-a" || $1 == "-alias" ]]; then - local alias=$2 - shift - elif [[ -n $1 ]]; then - [[ -n $versionOrAlias ]] && echo "Invalid option $1" && kvm help && return 1 - local versionOrAlias=$1 - fi - shift - done - if [[ "$versionOrAlias" == "latest" ]]; then - echo "Determining latest version" - versionOrAlias=$(_kvm_find_latest) - [[ $? == 1 ]] && echo "Error: Could not find latest version from feed $KRE_FEED" && return 1 - echo "Latest version is $versionOrAlias" - fi - if [[ "$versionOrAlias" == *.nupkg ]]; then - local kreFullName=$(basename $versionOrAlias | sed "s/\(.*\)\.nupkg/\1/") - local kreVersion=$(_kvm_package_version "$kreFullName") - local kreFolder="$KRE_USER_PACKAGES/$kreFullName" - local kreFile="$kreFolder/$kreFullName.nupkg" - - if [ -e "$kreFolder" ]; then - echo "$kreFullName already installed" - else - mkdir "$kreFolder" > /dev/null 2>&1 - cp -a "$versionOrAlias" "$kreFile" - _kvm_unpack "$kreFile" "$kreFolder" - [[ $? == 1 ]] && return 1 - fi - kvm use "$kreVersion" "$persistent" - [[ -n $alias ]] && kvm alias "$alias" "$kreVersion" - else - local kreFullName="$(_kvm_requested_version_or_alias $versionOrAlias)" - local kreFolder="$KRE_USER_PACKAGES/$kreFullName" - _kvm_download "$kreFullName" "$kreFolder" - [[ $? == 1 ]] && return 1 - kvm use "$versionOrAlias" "$persistent" - [[ -n $alias ]] && kvm alias "$alias" "$versionOrAlias" - fi - ;; - - "use" ) - [ $# -gt 3 ] && kvm help && return - [ $# -lt 2 ] && kvm help && return - - shift - local persistent= - while [ $# -ne 0 ] - do - if [[ $1 == "-p" || $1 == "-persistent" ]]; then - local persistent="true" - elif [[ -n $1 ]]; then - local versionOrAlias=$1 - fi - shift - done - - if [[ $versionOrAlias == "none" ]]; then - echo "Removing KRE from process PATH" - # Strip other version from PATH - PATH=$(_kvm_strip_path "$PATH" "/bin") - - if [[ -n $persistent && -e "$KRE_USER_HOME/alias/default.alias" ]]; then - echo "Setting default KRE to none" - rm "$KRE_USER_HOME/alias/default.alias" - fi - return 0 - fi - - local kreFullName=$(_kvm_requested_version_or_alias "$versionOrAlias") - local kreBin=$(_kvm_locate_kre_bin_from_full_name "$kreFullName") - - if [[ -z $kreBin ]]; then - echo "Cannot find $kreFullName, do you need to run 'kvm install $versionOrAlias'?" - return 1 - fi - - echo "Adding" $kreBin "to process PATH" - - PATH=$(_kvm_strip_path "$PATH" "/bin") - PATH=$(_kvm_prepend_path "$PATH" "$kreBin") - - if [[ -n $persistent ]]; then - local kreVersion=$(_kvm_package_version "$kreFullName") - kvm alias default "$kreVersion" - fi - ;; - - "alias" ) - [[ $# -gt 3 ]] && kvm help && return - - [[ ! -e "$KRE_USER_HOME/alias/" ]] && mkdir "$KRE_USER_HOME/alias/" > /dev/null - - if [[ $# == 1 ]]; then - echo "" - local format="%-20s %s\n" - printf "$format" "Alias" "Name" - printf "$format" "-----" "----" - for _kvm_file in $(find "$KRE_USER_HOME/alias" -name *.alias); do - local alias="$(basename $_kvm_file | sed 's/.alias//')" - local name="$(cat $_kvm_file)" - printf "$format" "$alias" "$name" - done - echo "" - return - fi - - local name="$2" - - if [[ $# == 2 ]]; then - [[ ! -e "$KRE_USER_HOME/alias/$name.alias" ]] && echo "There is no alias called '$name'" && return - cat "$KRE_USER_HOME/alias/$name.alias" - echo "" - return - fi - - local kreFullName=$(_kvm_requested_version_or_alias "$3") - - [[ ! -d "$KRE_USER_PACKAGES/$kreFullName" ]] && echo "$kreFullName is not an installed KRE version" && return 1 - - local action="Setting" - [[ -e "$KRE_USER_HOME/alias/$name.alias" ]] && action="Updating" - echo "$action alias '$name' to '$kreFullName'" - echo "$kreFullName" > "$KRE_USER_HOME/alias/$name.alias" - ;; - - "unalias" ) - [[ $# -ne 2 ]] && kvm help && return - - local name=$2 - local aliasPath="$KRE_USER_HOME/alias/$name.alias" - [[ ! -e "$aliasPath" ]] && echo "Cannot remove alias, '$name' is not a valid alias name" && return 1 - echo "Removing alias $name" - rm "$aliasPath" >> /dev/null 2>&1 - ;; - - "list" ) - [[ $# -gt 2 ]] && kvm help && return - - [[ ! -d $KRE_USER_PACKAGES ]] && echo "KRE is not installed." && return 1 - - local searchGlob="KRE-*" - if [ $# == 2 ]; then - local versionOrAlias=$2 - local searchGlob=$(_kvm_requested_version_or_alias "$versionOrAlias") - fi - echo "" - - local arr=() - local i=0 - local format="%-20s %s\n" - for _kvm_file in $(find "$KRE_USER_HOME/alias" -name *.alias); do - arr[$i]="$(basename $_kvm_file | sed 's/.alias//')/$(cat $_kvm_file)" - let i+=1 - done - - local formatString="%-6s %-20s %-7s %-20s %s\n" - printf "$formatString" "Active" "Version" "Runtime" "Location" "Alias" - printf "$formatString" "------" "-------" "-------" "--------" "-----" - - local formattedHome=`(echo $KRE_USER_PACKAGES | sed s=$HOME=~=g)` - for f in $(find $KRE_USER_PACKAGES/* -name "$searchGlob" -type d -prune -exec basename {} \;); do - local active="" - [[ $PATH == *"$KRE_USER_PACKAGES/$f/bin"* ]] && local active=" *" - local pkgName=$(_kvm_package_runtime "$f") - local pkgVersion=$(_kvm_package_version "$f") - - local alias="" - local delim="" - for i in "${arr[@]}"; do - temp="KRE-$pkgName.$pkgVersion" - temp2="KRE-$pkgName-x86.$pkgVersion" - if [[ ${i#*/} == $temp || ${i#*/} == $temp2 ]]; then - alias+="$delim${i%/*}" - delim=", " - fi - done - - printf "$formatString" "$active" "$pkgVersion" "$pkgName" "$formattedHome" "$alias" - [[ $# == 2 ]] && echo "" && return 0 - done - - echo "" - [[ $# == 2 ]] && echo "$versionOrAlias not found" && return 1 - ;; - - *) - echo "Unknown command $1" - return 1 - esac - - return 0 -} - -kvm list default >/dev/null && kvm use default >/dev/null || true diff --git a/kvminstall.ps1 b/kvminstall.ps1 deleted file mode 100644 index d2693188760a..000000000000 --- a/kvminstall.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -$tempPath = Join-Path $env:TEMP "kvminstall" -$kvmPs1Path = Join-Path $tempPath "kvm.ps1" -$kvmCmdPath = Join-Path $tempPath "kvm.cmd" - -Write-Host "Using temporary directory: $tempPath" -if (!(Test-Path $tempPath)) { md $tempPath | Out-Null } - - -$webClient = New-Object System.Net.WebClient -Write-Host "Downloading KVM.ps1 to $kvmPs1Path" -$webClient.DownloadFile('https://raw.githubusercontent.com/aspnet/Home/dev/kvm.ps1', $kvmPs1Path) -Write-Host "Downloading KVM.cmd to $kvmCmdPath" -$webClient.DownloadFile('https://raw.githubusercontent.com/aspnet/Home/dev/kvm.cmd', $kvmCmdPath) -Write-Host "Installing KVM" -& $kvmCmdPath setup \ No newline at end of file diff --git a/kvminstall.sh b/kvminstall.sh deleted file mode 100644 index 65e93363b640..000000000000 --- a/kvminstall.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash - -_kvmsetup_has() { - type "$1" > /dev/null 2>&1 - return $? -} - -_kvmsetup_update_profile() { - local profile="$1" - local sourceString="$2" - if ! grep -qc 'kvm.sh' $profile; then - echo "Appending source string to $profile" - echo "" >> "$profile" - echo $sourceString >> "$profile" - else - echo "=> Source string already in $profile" - fi -} - -if [ -z "$KRE_USER_HOME" ]; then - eval KRE_USER_HOME=~/.kre -fi - -if ! _kvmsetup_has "curl"; then - echo "kvmsetup requires curl to be installed" - return 1 -fi - -if [ -z "$KVM_SOURCE" ]; then - KVM_SOURCE="https://raw.githubusercontent.com/aspnet/Home/dev/kvm.sh" -fi - -# Downloading to $KVM_DIR -mkdir -p "$KRE_USER_HOME/kvm" -if [ -s "$KRE_USER_HOME/kvm/kvm.sh" ]; then - echo "kvm is already installed in $KRE_USER_HOME/kvm, trying to update" -else - echo "Downloading kvm as script to '$KRE_USER_HOME/kvm'" -fi - -curl -s "$KVM_SOURCE" -o "$KRE_USER_HOME/kvm/kvm.sh" || { - echo >&2 "Failed to download '$KVM_SOURCE'.." - return 1 -} - -echo - -# Detect profile file if not specified as environment variable (eg: PROFILE=~/.myprofile). -if [ -z "$PROFILE" ]; then - if [ -f "$HOME/.bash_profile" ]; then - PROFILE="$HOME/.bash_profile" - elif [ -f "$HOME/.bashrc" ]; then - PROFILE="$HOME/.bashrc" - elif [ -f "$HOME/.profile" ]; then - PROFILE="$HOME/.profile" - fi -fi - -if [ -z "$ZPROFILE" ]; then - if [ -f "$HOME/.zshrc" ]; then - ZPROFILE="$HOME/.zshrc" - fi -fi - -SOURCE_STR="[ -s \"$KRE_USER_HOME/kvm/kvm.sh\" ] && . \"$KRE_USER_HOME/kvm/kvm.sh\" # Load kvm" - -if [ -z "$PROFILE" -a -z "$ZPROFILE" ] || [ ! -f "$PROFILE" -a ! -f "$ZPROFILE" ] ; then - if [ -z "$PROFILE" ]; then - echo "Profile not found. Tried ~/.bash_profile ~/.zshrc and ~/.profile." - echo "Create one of them and run this script again" - elif [ ! -f "$PROFILE" ]; then - echo "Profile $PROFILE not found" - echo "Create it (touch $PROFILE) and run this script again" - else - echo "Profile $ZPROFILE not found" - echo "Create it (touch $ZPROFILE) and run this script again" - fi - echo " OR" - echo "Append the following line to the correct file yourself:" - echo - echo " $SOURCE_STR" - echo -else - [ -n "$PROFILE" ] && _kvmsetup_update_profile "$PROFILE" "$SOURCE_STR" - [ -n "$ZPROFILE" ] && _kvmsetup_update_profile "$ZPROFILE" "$SOURCE_STR" -fi - -echo "Type 'source $KRE_USER_HOME/kvm/kvm.sh' to start using kvm" diff --git a/samples/ConsoleApp/Program.cs b/samples/ConsoleApp/Program.cs deleted file mode 100644 index 7ee7ee1dc5e9..000000000000 --- a/samples/ConsoleApp/Program.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -public class Program -{ - public static void Main() - { - Console.WriteLine("Hello World"); - } -} diff --git a/samples/ConsoleApp/project.json b/samples/ConsoleApp/project.json deleted file mode 100644 index 4545d5367117..000000000000 --- a/samples/ConsoleApp/project.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "dependencies": { - "System.Console": "4.0.0.0" - }, - "frameworks": { - "net45": {}, - "k10": {} - } -} \ No newline at end of file diff --git a/samples/HelloMvc/Controllers/HomeController.cs b/samples/HelloMvc/Controllers/HomeController.cs deleted file mode 100644 index 67b912a02f76..000000000000 --- a/samples/HelloMvc/Controllers/HomeController.cs +++ /dev/null @@ -1,24 +0,0 @@ -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; - } - } -} \ No newline at end of file diff --git a/samples/HelloMvc/Models/User.cs b/samples/HelloMvc/Models/User.cs deleted file mode 100644 index 9869e92d13af..000000000000 --- a/samples/HelloMvc/Models/User.cs +++ /dev/null @@ -1,13 +0,0 @@ -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; } - } -} \ No newline at end of file diff --git a/samples/HelloMvc/Startup.cs b/samples/HelloMvc/Startup.cs deleted file mode 100644 index eb17e8a18c8e..000000000000 --- a/samples/HelloMvc/Startup.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.AspNet.Builder; -using Microsoft.AspNet.Routing; -using Microsoft.Framework.DependencyInjection; - -namespace HelloMvc -{ - public class Startup - { - public void Configure(IApplicationBuilder app) - { - app.UseErrorPage(); - - app.UseServices(services => - { - services.AddMvc(); - }); - - app.UseMvc(); - - app.UseWelcomePage(); - } - } -} \ No newline at end of file diff --git a/samples/HelloMvc/Views/Home/Index.cshtml b/samples/HelloMvc/Views/Home/Index.cshtml deleted file mode 100644 index b786e64b5e81..000000000000 --- a/samples/HelloMvc/Views/Home/Index.cshtml +++ /dev/null @@ -1,16 +0,0 @@ -@using MvcSample.Web.Models -@model User -@{ - Layout = "/Views/Shared/_Layout.cshtml"; - ViewBag.Title = "Home Page"; - string helloClass = null; -} - -
-

ASP.NET

-

ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.

-

Learn more »

-
-
-

Hello @Model.Name!

-
diff --git a/samples/HelloMvc/Views/Shared/_Layout.cshtml b/samples/HelloMvc/Views/Shared/_Layout.cshtml deleted file mode 100644 index 3377694bed23..000000000000 --- a/samples/HelloMvc/Views/Shared/_Layout.cshtml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - @ViewBag.Title - My ASP.NET Application - - - - -
- @RenderBody() -
-
- @if (@Model != null) - { - @Model.Address - } -
- -
- - diff --git a/samples/HelloMvc/project.json b/samples/HelloMvc/project.json deleted file mode 100644 index 36082d31f816..000000000000 --- a/samples/HelloMvc/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "dependencies": { - "Kestrel": "1.0.0-*", - "Microsoft.AspNet.Diagnostics": "1.0.0-*", - "Microsoft.AspNet.Hosting": "1.0.0-*", - "Microsoft.AspNet.Mvc": "6.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*" - }, - "commands": { - "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001", - "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004" - }, - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { } - } -} \ No newline at end of file diff --git a/samples/HelloWeb/Startup.cs b/samples/HelloWeb/Startup.cs deleted file mode 100644 index b41f459f03d7..000000000000 --- a/samples/HelloWeb/Startup.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Microsoft.AspNet.Builder; - -namespace KWebStartup -{ - public class Startup - { - public void Configure(IApplicationBuilder app) - { - app.UseStaticFiles(); - app.UseWelcomePage(); - } - } -} \ No newline at end of file diff --git a/samples/HelloWeb/image.jpg b/samples/HelloWeb/image.jpg deleted file mode 100644 index 899595259f33..000000000000 Binary files a/samples/HelloWeb/image.jpg and /dev/null differ diff --git a/samples/HelloWeb/project.json b/samples/HelloWeb/project.json deleted file mode 100644 index 583d9546b57a..000000000000 --- a/samples/HelloWeb/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "dependencies": { - "Kestrel": "1.0.0-*", - "Microsoft.AspNet.Diagnostics": "1.0.0-*", - "Microsoft.AspNet.Hosting": "1.0.0-*", - "Microsoft.AspNet.Server.WebListener": "1.0.0-*", - "Microsoft.AspNet.StaticFiles": "1.0.0-*" - }, - "commands": { - "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001", - "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004" - }, - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { } - } -} \ No newline at end of file