Skip to content

Commit

Permalink
Update build tools used by ILSpy to use .NET 5.0 instead of .NET Core…
Browse files Browse the repository at this point in the history
… 3.1
  • Loading branch information
siegfriedpammer committed Jun 6, 2021
1 parent 7af9d36 commit 35ad7f3
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-frontends.yml
Expand Up @@ -15,10 +15,10 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup .NET Core
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
dotnet-version: 5.0.x
- name: Install dependencies
run: dotnet restore Frontends.sln
- name: Build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-ilspy.yml
Expand Up @@ -39,10 +39,10 @@ jobs:
submodules: true
fetch-depth: 0

- name: Setup .NET Core 3.1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.x'
dotnet-version: 5.0.x

- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1.0.2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Expand Up @@ -27,10 +27,10 @@ jobs:
with:
languages: ${{ matrix.language }}

- name: Setup .NET Core
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.x
dotnet-version: 5.0.x
- name: Build
run: dotnet build Frontends.sln --configuration Release

Expand Down
2 changes: 1 addition & 1 deletion .vsconfig
Expand Up @@ -3,7 +3,7 @@
"components": [
"Microsoft.VisualStudio.Component.CoreEditor",
"Microsoft.VisualStudio.Workload.CoreEditor",
"Microsoft.NetCore.Component.Runtime.3.1",
"Microsoft.NetCore.Component.Runtime.5.0",
"Microsoft.NetCore.Component.SDK",
"Microsoft.VisualStudio.Component.NuGet",
"Microsoft.VisualStudio.Component.Roslyn.Compiler",
Expand Down
8 changes: 4 additions & 4 deletions ICSharpCode.Decompiler.Tests/Helpers/Tester.cs
Expand Up @@ -219,9 +219,9 @@ private static string ReplacePrivImplDetails(string il)

static readonly RoslynToolset roslynToolset = new RoslynToolset();

static readonly string coreRefAsmPath = new DotNetCorePathFinder(TargetFrameworkIdentifier.NETCoreApp,
new Version(3, 1), "Microsoft.NETCore.App")
.GetReferenceAssemblyPath(".NETCoreApp, Version = v3.1");
static readonly string coreRefAsmPath = new DotNetCorePathFinder(TargetFrameworkIdentifier.NET,
new Version(5, 0), "Microsoft.NETCore.App")
.GetReferenceAssemblyPath(".NETCoreApp, Version = v5.0");

static readonly string refAsmPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86),
@"Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2");
Expand Down Expand Up @@ -257,7 +257,7 @@ private static string ReplacePrivImplDetails(string il)

const string targetFrameworkAttributeSnippet = @"
[assembly: System.Runtime.Versioning.TargetFramework("".NETCoreApp, Version = v3.1"", FrameworkDisplayName = """")]
[assembly: System.Runtime.Versioning.TargetFramework("".NETCoreApp, Version = v5.0"", FrameworkDisplayName = """")]
";

Expand Down
4 changes: 4 additions & 0 deletions ICSharpCode.Decompiler/Metadata/DotNetCorePathFinder.cs
Expand Up @@ -168,6 +168,10 @@ internal string GetReferenceAssemblyPath(string targetFramework)
identifier = "NETStandard.Library";
identifierExt = "netstandard" + version.Major + "." + version.Minor;
break;
case TargetFrameworkIdentifier.NET:
identifier = "Microsoft.NETCore.App";
identifierExt = "net" + version.Major + "." + version.Minor;
break;
default:
throw new NotSupportedException();
}
Expand Down
7 changes: 6 additions & 1 deletion ICSharpCode.Decompiler/Metadata/UniversalAssemblyResolver.cs
Expand Up @@ -36,7 +36,8 @@ public enum TargetFrameworkIdentifier
NETFramework,
NETCoreApp,
NETStandard,
Silverlight
Silverlight,
NET
}

enum DecompilerRuntime
Expand Down Expand Up @@ -186,6 +187,9 @@ internal static (TargetFrameworkIdentifier, Version) ParseTargetFramework(string
}
if (!Version.TryParse(versionString, out version))
version = null;
// .NET 5 or greater still use ".NETCOREAPP" as TargetFrameworkAttribute value...
if (version?.Major >= 5 && identifier == TargetFrameworkIdentifier.NETCoreApp)
identifier = TargetFrameworkIdentifier.NET;
break;
}
}
Expand Down Expand Up @@ -260,6 +264,7 @@ public override bool IsSharedAssembly(IAssemblyReference reference, [NotNullWhen
string? file;
switch (targetFrameworkIdentifier)
{
case TargetFrameworkIdentifier.NET:
case TargetFrameworkIdentifier.NETCoreApp:
case TargetFrameworkIdentifier.NETStandard:
if (IsZeroOrAllOnes(targetFrameworkVersion))
Expand Down
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -49,7 +49,7 @@ How to build
- Follow Microsoft's instructions for [importing a configuration](https://docs.microsoft.com/en-us/visualstudio/install/import-export-installation-configurations?view=vs-2019#import-a-configuration), and import the .vsconfig file located at the root of the solution.
- Alternatively, you can open the ILSpy solution (ILSpy.sln) and Visual Studio will [prompt you to install the missing components](https://docs.microsoft.com/en-us/visualstudio/install/import-export-installation-configurations?view=vs-2019#automatically-install-missing-components).
- Finally, you can manually install the necessary components via the Visual Studio Installer. The workloads/components are as follows:
- Workload ".NET Desktop Development". This workload includes the .NET Framework 4.8 SDK and the .NET Framework 4.7.2 targeting pack, as well as the [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1) (ILSpy.csproj targets .NET 4.7.2, and ILSpy.sln uses SDK-style projects). _Note: The optional components of this workload are not required for ILSpy_
- Workload ".NET Desktop Development". This workload includes the .NET Framework 4.8 SDK and the .NET Framework 4.7.2 targeting pack, as well as the [.NET 5.0 SDK](https://dotnet.microsoft.com/download/dotnet/5.0) (ILSpy.csproj targets .NET 4.7.2, and ILSpy.sln uses SDK-style projects). _Note: The optional components of this workload are not required for ILSpy_
- Workload "Visual Studio extension development" (ILSpy.sln contains a VS extension project) _Note: The optional components of this workload are not required for ILSpy_
- Individual Component "MSVC v142 - VS 2019 C++ x64/x86 build tools (v14.23)" (or similar)
- _The VC++ toolset is optional_; if present it is used for `editbin.exe` to modify the stack size used by ILSpy.exe from 1MB to 16MB, because the decompiler makes heavy use of recursion, where small stack sizes lead to problems in very complex methods.
Expand All @@ -58,14 +58,14 @@ How to build
- Run project "ILSpy" for the ILSpy UI
- Use the Visual Studio "Test Explorer" to see/run the tests

**Note:** Visual Studio 16.3 and later include a version of the .NET Core SDK that is managed by the Visual Studio installer - once you update, it may get upgraded too.
Please note that ILSpy is only compatible with the .NET Core 3.1 SDK and Visual Studio will refuse to load some projects in the solution (and unit tests will fail).
If this problem occurs, please manually install the .NET Core 3.1 SDK from [here](https://dotnet.microsoft.com/download/dotnet-core/3.1).
**Note:** Visual Studio 16.3 and later include a version of the .NET (Core) SDK that is managed by the Visual Studio installer - once you update, it may get upgraded too.
Please note that ILSpy is only compatible with the .NET 5.0 SDK and Visual Studio will refuse to load some projects in the solution (and unit tests will fail).
If this problem occurs, please manually install the .NET 5.0 SDK from [here](https://dotnet.microsoft.com/download/dotnet/5.0).

#### Unix / Mac:

- Make sure .NET Core 2.1 LTS Runtime is installed (you can get it here: https://get.dot.net).
- Make sure [.NET Core 3.1 SDK](https://dotnet.microsoft.com/download/dotnet-core/3.1) is installed.
- Make sure [.NET 5.0 SDK](https://dotnet.microsoft.com/download/dotnet/5.0) is installed.
- Make sure [PowerShell](https://github.com/PowerShell/PowerShell) is installed (formerly known as PowerShell Core)
- Clone the repository using git.
- Execute `git submodule update --init --recursive` to download the ILSpy-Tests submodule (used by some test cases).
Expand Down
2 changes: 1 addition & 1 deletion global.json
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "3.1.100",
"version": "5.0.0",
"rollForward": "major",
"allowPrerelease": true
}
Expand Down

0 comments on commit 35ad7f3

Please sign in to comment.