From 2cac937bac1035c76c379615ca1f142ba196592c Mon Sep 17 00:00:00 2001 From: Rich Lander Date: Thu, 23 Apr 2015 17:32:33 -0700 Subject: [PATCH] Add instructions for acquiring binaries for Windows via NuGet Commit migrated from https://github.com/dotnet/coreclr/commit/1d789e6857e98354f68dff102bbb20e3fe783a15 --- docs/coreclr/README.md | 9 ++- docs/coreclr/get-coreclr-windows.md | 101 ++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 docs/coreclr/get-coreclr-windows.md diff --git a/docs/coreclr/README.md b/docs/coreclr/README.md index b0aea805a05..61c6caece86 100644 --- a/docs/coreclr/README.md +++ b/docs/coreclr/README.md @@ -3,8 +3,13 @@ Documents Index This repo includes several documents that explain both high-level and low-level concepts about the .NET runtime. These are very useful for contributors, to get context that can be very difficult to acquire from just reading code. -Product Instructions -==================== +Get CoreCLR +=========== + +- [Get CoreCLR on Windows](get-coreclr-windows.md) + +Build CoreCLR from Source +========================= - [Building CoreCLR on Linux](linux-instructions.md) - [Building CoreCLR on OS X](osx-instructions.md) diff --git a/docs/coreclr/get-coreclr-windows.md b/docs/coreclr/get-coreclr-windows.md new file mode 100644 index 00000000000..60953a5b256 --- /dev/null +++ b/docs/coreclr/get-coreclr-windows.md @@ -0,0 +1,101 @@ +Get CoreCLR on Windows +====================== + +These instructions will lead you through acquiring CoreCLR and running a "Hello World" demo on Windows. The instructions use a particular set of paths. You'll need to adjust if you want to use a different set. + +CoreCLR is distributed as NuGet packages. There is no installer or other distribution mechanism, other than [building from source](windows-instructions.md). You acquire CoreCLR via the normal NuGet restore experience. + +You can see the [CoreCLR myget feed](https://www.myget.org/F/dotnet-core) @ the [dotnet-core gallery](https://www.myget.org/gallery/dotnet-core) page. These packages are not yet published to NuGet.org, but that will change soon. + +NuGet Restore Packages +====================== + +Given that NuGet is the .NET Core distribution mechanism, you need a packages.config to restore the packages. The following packages.config is the most minimal one you can have for console apps. You will need to add packages if your app needs it Save this XML to ```c:\coreclr-demo\packages\packages.config```. + +``` + + + + + + + + + + + + + + + + + + + + + + +``` + +You will need to update the version numbers to acquire later versions of the NuGet packages. If you do, you'll need to update the copy commands later in the instructions to accomodate. NuGet supports wildcard versions, such as ```version="4.0.0-beta-*"```, which can be helpful. + +Download the [NuGet client](https://nuget.org/nuget.exe) if you don't already have it in your path. You can grab it from: https://nuget.org/nuget.exe. Save it to ```c:\coreclr-demo```. + +You need to restore the packages to the packages directory. + + C:\coreclr-demo>nuget restore packages\packages.config -Source https://www.myget.org/F/dotnet-core/ -PackagesDirectory packages + +Write your App +============== + +You need a Hello World application to run. You can write your own, if you'd like. Here's a very simple one: + + using System; + + public class Program + { + public static void Main (string[] args) + { + Console.WriteLine("Hello, Windows"); + Console.WriteLine("Love from CoreCLR."); + } + } + +Some people on the .NET Core team are partial to a demo console app on corefxlab repo which will print a picture for you. Download the [corefxlab demo](https://raw.githubusercontent.com/dotnet/corefxlab/master/demos/CoreClrConsoleApplications/HelloWorld/HelloWorld.cs) to ```C:\coreclr-demo```. + +Compile your App +================ + +You need to build your app with csc, the .NET Framework C# compiler. It may be easier to do this step within the "Developer Command Prompt for VS2013", if csc is not in your path. You need to pass references to the contract assemblies you restored using NuGet to compile the app against the .NET Core surface area: + + C:\coreclr-demo>md app + + C:\coreclr-demo>csc /nostdlib /noconfig /r:packages\System.Runtime.4.0.20-beta-22703\lib\contract\System.Runtime.dll /r:packages\System.Console.4.0.0-beta-22703\lib\contract\System.Console.dll /out:app\HelloWorld.dll HelloWorld.cs + +It might seem odd, but this command compiles your app to a DLL. That's intended. + +Prepare the demo +================ + +You need to copy the NuGet package assemblies over to the app folder. You need to run a few commands, including a little batch magic. + + C:\coreclr-demo>for /f %k in ('dir /s /b packages\*.dll') do echo %k | findstr "\aspnetcore50" && copy /Y %k app + + C:\coreclr-demo>copy packages\Microsoft.NETCore.Runtime.CoreCLR-x64.1.0.0-beta-22819\lib\any~win\x64\* app + + C:\coreclr-demo>copy packages\Microsoft.NETCore.Runtime.CoreCLR.ConsoleHost-x64.1.0.0-beta-22819\native\win\x64\CoreConsole.exe app\HelloWorld.exe + +This last step might be a bit surprising, copying ```CoreConsole.exe``` to MyApp.exe, in this case ```HelloWorld.exe```. This is closedly related to compiling the app, in the instructions above, to MyApp.dll, in this case to ```HelloWorld.dll```. + +We've grown very fond of creating and using managed EXEs that don't require a separate launcher with the .NET Framework on Windows. We wanted the same experience for .NET Core. To enable the experience, we created a launcher that expects a managed assembly of the same name, compiled with a static main method. As a case in point, if you run ```CoreConsole.exe``` without renaming it, it will expect a ```CoreConsole.dll```. The renaming step, which you see above, needs to match the main assembly, compiled as a DLL, and you get an experience that feels launcher-less. + +Run the demo +============ + +You're ready to run Hello World! + + C:\coreclr-demo>app\HelloWorld.exe + Hello, Windows + Love from CoreCLR. + +Thanks for trying out CoreCLR. Feel free to try a more interesting demo. \ No newline at end of file