I have created a NuGet package from .NET4.0 DLLs which include mixed (Managed and native) code.
The Native code is packaged up inside the .NET4.0 DLL but has a dependency on the Visual C++ 2013 Redistributable
I'm trying to brainstorm ways to either package the redist with the NuGet package and/or warn the user that they need it, but I'm drawing a blank.
Anyone got any ideas?
I actually kind'of solved this myself. While I couldn't find a solution to include the VCpp Runtime as a dependency to a NuGet package, I did find a solution to warn the user that the Visual C++ 2013 Runtime was needed.
I run this code once, statically, at startup of the component/library that requires the VC++ Runtime:
private static void AssertVcppDependencies()
{
var system32Path = Environment.GetFolderPath(Environment.SpecialFolder.SystemX86);
var system64Path = Environment.GetFolderPath(Environment.SpecialFolder.System);
string platform = Environment.Is64BitProcess ? "x64 and x86" : "x86";
bool success = File.Exists(Path.Combine(system32Path, MSVCP120DllName));
if (Environment.Is64BitProcess)
{
success &= File.Exists(Path.Combine(system64Path, MSVCP120DllName));
}
if (!success)
{
throw new InvalidOperationException("This Application Requires the Visual C++ 2013 " + platform +
" Runtime to be installed on this computer. Please download and install it from https://www.microsoft.com/en-GB/download/details.aspx?id=40784");
}
}
This should alert any developers that are consuming your NuGet package that they need to install the runtime.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With