Skip to content

Commit

Permalink
Include System.Memory.dll and System.Runtime.CompilerServices.Unsafe.…
Browse files Browse the repository at this point in the history
…dll for VS 2017 build tools

Fixes #589
  • Loading branch information
AArnott committed Apr 15, 2021
1 parent 8126d95 commit 162443a
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion global.json
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "5.0.100"
"version": "5.0.202"
}
}
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Expand Up @@ -4,7 +4,7 @@
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)..\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<OutputPath>$(MSBuildThisFileDirectory)..\bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
<DocumentationRootFolder>$(MSBuildThisFileDirectory)..\wiki\api</DocumentationRootFolder>
<LangVersion>8.0</LangVersion>
<LangVersion>9.0</LangVersion>

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)strongname.snk</AssemblyOriginatorKeyFile>
Expand Down
48 changes: 48 additions & 0 deletions src/Nerdbank.GitVersioning.Tasks/AssemblyLoader.cs
@@ -0,0 +1,48 @@
#if NETFRAMEWORK

using System;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;

namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class ModuleInitializerAttribute : Attribute { }
}

namespace Nerdbank.GitVersioning.Tasks
{
internal static class AssemblyLoader
{
[ModuleInitializer]
internal static void LoaderInitializer()
{
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}

private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
try
{
var required = new AssemblyName(args.Name);
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), required.Name + ".dll");
if (File.Exists(path))
{
AssemblyName actual = AssemblyName.GetAssemblyName(path);
if (actual.Version >= required.Version)
{
return Assembly.LoadFile(path);
}
}
}
catch
{
}

return null;
}
}
}

#endif
Expand Up @@ -27,6 +27,10 @@ IMPORTANT: The 3.x release may produce a different version height than prior maj
<file src="$BaseOutputPath$net461\Validation.dll" target="build\MSBuildFull\Validation.dll" />
<file src="$BaseOutputPath$net461\System.Runtime.CompilerServices.Unsafe.dll" target="build\MSBuildFull\System.Runtime.CompilerServices.Unsafe.dll" />
<file src="$BaseOutputPath$net461\PInvoke.Kernel32.dll" target="build\MSBuildFull\PInvoke.Kernel32.dll" />
<file src="$BaseOutputPath$net461\System.Buffers.dll" target="build\MSBuildFull\System.Buffers.dll" />
<file src="$BaseOutputPath$net461\System.Memory.dll" target="build\MSBuildFull\System.Memory.dll" />
<file src="$BaseOutputPath$net461\System.Runtime.CompilerServices.Unsafe.dll" target="build\MSBuildFull\System.Runtime.CompilerServices.Unsafe.dll" />
<file src="$BaseOutputPath$net461\System.Numerics.Vectors.dll" target="build\MSBuildFull\System.Numerics.Vectors.dll" />
<file src="$LibGit2SharpNativeBinaries$runtimes\**" target="build\runtimes\" />

<!-- Additional copies to work around DllNotFoundException on Mono (https://github.com/dotnet/Nerdbank.GitVersioning/issues/222) -->
Expand Down

0 comments on commit 162443a

Please sign in to comment.