Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Include BCL assemblies required for VS 2017 build tools
Several assemblies are required by this msbuild task but are not included in MSBuild 2017. Adding the assemblies to the package alone is not enough, since binding redirects are also missing in msbuild.exe.config. We make up for this with a custom assembly resolver. Fixes #589
- Loading branch information
Showing
4 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"sdk": { | ||
"version": "5.0.100" | ||
"version": "5.0.202" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters