Skip to content

Commit dd15b12

Browse files
svickjkotas
authored andcommitted
Update Windows instructions (dotnet#5312)
* Small improvements to Windows instructions * copy missing System.Private.CoreLib.dll * syntax highlighting * Use ref assemblies from CoreFX instead of NuGet * Used AnyOS directories for CoreFX assemblies Also use built facade assemblies. AnyOS directories are safer, since they don't rely on tests to be built. (Building main project usually creates just AnyOS, building test project creates the Windows_NT version.)
1 parent 8868f88 commit dd15b12

File tree

1 file changed

+52
-72
lines changed

1 file changed

+52
-72
lines changed

Documentation/building/windows-instructions.md

Lines changed: 52 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ Git Setup
4646

4747
Clone the CoreCLR and CoreFX repositories (either upstream or a fork).
4848

49-
C:\git>git clone https://github.com/dotnet/coreclr
50-
C:\git>git clone https://github.com/dotnet/corefx
49+
```bat
50+
C:\git>git clone https://github.com/dotnet/coreclr
51+
C:\git>git clone https://github.com/dotnet/corefx
52+
```
5153

5254
This guide assumes that you've cloned the CoreCLR and CoreFX repositories into C:\git using the default repo names. If your setup is different, you'll need to pay attention to the commands you run. The guide will always show you the current directory.
5355

@@ -58,15 +60,10 @@ Demo directory
5860

5961
In order to keep everything tidy, create a new directory for the files that you will build or acquire.
6062

61-
c:\git>mkdir \coreclr-demo\runtime
62-
c:\git>mkdir \coreclr-demo\packages
63-
64-
NuGet
65-
-----
66-
67-
NuGet is required to acquire any .NET assembly dependency that is not built by these instructions.
68-
69-
Download the [NuGet client](https://nuget.org/nuget.exe) and copy to c:\coreclr-demo. Alternatively, you can download nuget.exe, put it somewhere else, and add it to your PATH.
63+
```bat
64+
c:\git>mkdir \coreclr-demo\runtime
65+
c:\git>mkdir \coreclr-demo\ref
66+
```
7067

7168
Build the Runtime
7269
=================
@@ -100,10 +97,13 @@ You will see several files. The interesting ones are:
10097

10198
Copy these files into the demo directory.
10299

103-
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\clrjit.dll \coreclr-demo\runtime
104-
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\CoreRun.exe \coreclr-demo\runtime
105-
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\coreclr.dll \coreclr-demo\runtime
106-
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\mscorlib.dll \coreclr-demo\runtime
100+
```bat
101+
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\clrjit.dll \coreclr-demo\runtime
102+
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\CoreRun.exe \coreclr-demo\runtime
103+
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\coreclr.dll \coreclr-demo\runtime
104+
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\mscorlib.dll \coreclr-demo\runtime
105+
C:\git\coreclr>copy bin\Product\Windows_NT.x64.debug\System.Private.CoreLib.dll \coreclr-demo\runtime
106+
```
107107

108108
Build the Framework
109109
===================
@@ -123,82 +123,62 @@ It's also possible to add /t:rebuild to build.cmd to force it to delete the prev
123123

124124
For the purposes of this demo, you need to copy a few required assemblies to the demo folder.
125125

126-
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Console\System.Console.dll \coreclr-demo\runtime
127-
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Diagnostics.Debug\System.Diagnostics.Debug.dll \coreclr-demo\runtime
128-
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Threading\System.Threading.dll \coreclr-demo\runtime
129-
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.IO\System.IO.dll \coreclr-demo\runtime
130-
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.IO.FileSystem.Primitives\System.IO.FileSystem.Primitives.dll \coreclr-demo\runtime
131-
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Runtime\System.Runtime.dll \coreclr-demo\runtime
132-
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Runtime.Extensions\System.Runtime.Extensions.dll \coreclr-demo\runtime C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Runtime.InteropServices\System.Runtime.InteropServices.dll \coreclr-demo\runtime
133-
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Threading.Tasks\System.Threading.Tasks.dll \coreclr-demo\runtime
134-
135-
Restore NuGet Packages
136-
======================
137-
138-
You need to restore/download the rest of the demo dependencies via NuGet, as they are not yet part of the CoreFX repo. At present, these NuGet dependencies contain facades (type forwarders) that point to mscorlib.
139-
140-
Make a packages/packages.config file with the following XML. These packages are the required dependencies of this particular app. Different apps will have different dependencies and require different packages.config - see [Issue #480](https://github.com/dotnet/coreclr/issues/480).
141-
142-
```
143-
<?xml version="1.0" encoding="utf-8"?>
144-
<packages>
145-
<package id="System.Console" version="4.0.0-beta-23516" />
146-
<package id="System.Diagnostics.Contracts" version="4.0.1-beta-23516" />
147-
<package id="System.Diagnostics.Debug" version="4.0.11-beta-23516" />
148-
<package id="System.Diagnostics.Tools" version="4.0.1-beta-23516" />
149-
<package id="System.Globalization" version="4.0.11-beta-23516" />
150-
<package id="System.IO" version="4.0.11-beta-23516" />
151-
<package id="System.IO.FileSystem.Primitives" version="4.0.1-beta-23516" />
152-
<package id="System.Runtime" version="4.0.21-beta-23516" />
153-
<package id="System.Runtime.Extensions" version="4.0.11-beta-23516" />
154-
<package id="System.Runtime.Handles" version="4.0.1-beta-23516" />
155-
<package id="System.Runtime.InteropServices" version="4.0.21-beta-23516" />
156-
<package id="System.Text.Encoding" version="4.0.11-beta-23516" />
157-
<package id="System.Text.Encoding.Extensions" version="4.0.11-beta-23516" />
158-
<package id="System.Threading" version="4.0.11-beta-23516" />
159-
<package id="System.Threading.Tasks" version="4.0.11-beta-23516" />
160-
</packages>
126+
```bat
127+
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Console\System.Console.dll \coreclr-demo\runtime
128+
C:\git\corefx>copy bin\Windows_NT.AnyCPU.Debug\System.Diagnostics.Debug\System.Diagnostics.Debug.dll \coreclr-demo\runtime
129+
C:\git\corefx>copy bin\AnyOS.AnyCPU.Debug\System.IO\System.IO.dll \coreclr-demo\runtime
130+
C:\git\corefx>copy bin\AnyOS.AnyCPU.Debug\System.IO.FileSystem.Primitives\System.IO.FileSystem.Primitives.dll \coreclr-demo\runtime
131+
C:\git\corefx>copy bin\AnyOS.AnyCPU.Debug\System.Runtime\System.Runtime.dll \coreclr-demo\runtime
132+
C:\git\corefx>copy bin\AnyOS.AnyCPU.Debug\System.Runtime.InteropServices\System.Runtime.InteropServices.dll \coreclr-demo\runtime
133+
C:\git\corefx>copy bin\AnyOS.AnyCPU.Debug\System.Text.Encoding\System.Text.Encoding.dll \coreclr-demo\runtime
134+
C:\git\corefx>copy bin\AnyOS.AnyCPU.Debug\System.Text.Encoding.Extensions\System.Text.Encoding.Extensions.dll \coreclr-demo\runtime
135+
C:\git\corefx>copy bin\AnyOS.AnyCPU.Debug\System.Threading\System.Threading.dll \coreclr-demo\runtime
136+
C:\git\corefx>copy bin\AnyOS.AnyCPU.Debug\System.Threading.Tasks\System.Threading.Tasks.dll \coreclr-demo\runtime
161137
```
162138

163-
And restore the packages with the packages.config:
139+
You also need to copy reference assemblies, which will be used during compilation.
164140

165-
C:\coreclr-demo>nuget restore packages\packages.config -Source https://api.nuget.org/v3/index.json -PackagesDirectory packages
141+
```bat
142+
C:\git\corefx>copy bin\ref\System.Runtime\4.0.0.0\System.Runtime.dll \coreclr-demo\ref
143+
C:\git\corefx>copy bin\ref\System.Console\4.0.0.0\System.Console.dll \coreclr-demo\ref
144+
```
166145

167146
Compile the Demo
168147
================
169148

170149
Now you need a Hello World application to run. You can write your own, if you'd like. Here's a very simple one:
171150

172-
using System;
173-
174-
public class Program
175-
{
176-
public static void Main (string[] args)
177-
{
178-
Console.WriteLine("Hello, Windows");
179-
Console.WriteLine("Love from CoreCLR.");
180-
}
181-
}
151+
```C#
152+
using System;
153+
154+
public class Program
155+
{
156+
public static void Main()
157+
{
158+
Console.WriteLine("Hello, Windows");
159+
Console.WriteLine("Love from CoreCLR.");
160+
}
161+
}
162+
```
182163

183164
Personally, I'm partial to the one on corefxlab which will print a picture for you. Download the [corefxlab demo](https://raw.githubusercontent.com/dotnet/corefxlab/master/demos/CoreClrConsoleApplications/HelloWorld/HelloWorld.cs) to `\coreclr-demo`.
184165

185-
Then you just need to build it, 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. Because you need to compile the app against the .NET Core surface area, you need to pass references to the contract assemblies you restored using NuGet:
166+
Then you just need to build it, with csc, the .NET Framework C# compiler. It may be easier to do this step within the "Developer Command Prompt for VS2015", if csc is not in your path. Because you need to compile the app against the .NET Core surface area, you need to pass references to the contract assemblies you restored using NuGet:
186167

187-
```
188-
csc /nostdlib /noconfig /r:packages\System.Runtime.4.0.21-beta-23516\ref\dotnet5.1\System.Runtime.dll /r:packages\System.Console.4.0.0-beta-23516\ref\dotnet5.1\System.Console.dll /out:runtime\hello.exe hello.cs
168+
```bat
169+
csc /nostdlib /noconfig /r:ref\System.Runtime.dll /r:ref\System.Console.dll /out:runtime\hello.exe hello.cs
189170
```
190171

191172
Run the demo
192173
============
193174

194-
You'll also need the following facade assemblies from your packages folder:
195-
196-
C:\coreclr-demo>copy packages\System.Text.Encoding.4.0.11-beta-23516\lib\netcore50\System.Text.Encoding.dll runtime
197-
C:\coreclr-demo>copy packages\System.Text.Encoding.Extensions.4.0.11-beta-23516\lib\netcore50\System.Text.Encoding.Extensions.dll runtime
198-
199175
You're ready to run Hello World! To do that, run corerun, passing the path to the managed exe, plus any arguments. In this case, no arguments are necessary.
200176

201-
C:\coreclr-demo>cd runtime
202-
C:\coreclr-demo\runtime>CoreRun.exe HelloWorld.exe
177+
```bat
178+
C:\coreclr-demo>cd runtime
179+
C:\coreclr-demo\runtime>CoreRun.exe hello.exe
180+
```
181+
182+
If `CoreRun.exe` fails for some reason, you will see an empty output. To diagnose the issue, you can use `/v` to switch verbose mode on: `CoreRun.exe /v hello.exe`.
203183

204184
Over time, this process will get easier. Thanks for trying out CoreCLR. Feel free to try a more interesting demo.

0 commit comments

Comments
 (0)