Dr.*_*ABT 10 c# c++ visual-c++ nuget nuget-package
我从.NET4.0 DLL创建了一个NuGet包,其中包括混合(托管和本机)代码.
Native代码打包在.NET4.0 DLL中,但依赖于Visual C++ 2013 Redistributable
我正在尝试集体讨论如何使用NuGet包打包redist和/或警告用户他们需要它,但我正在画一个空白.
有人有任何想法吗?
我实际上自己解决了这个问题。虽然我找不到将 VCpp 运行时作为 NuGet 包的依赖项包含在内的解决方案,但我确实找到了一个解决方案来警告用户需要 Visual C++ 2013 运行时。
我在需要 VC++ 运行时的组件/库启动时静态运行此代码一次:
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");
}
}
Run Code Online (Sandbox Code Playgroud)
这应该提醒任何正在使用 NuGet 包的开发人员他们需要安装运行时。
| 归档时间: |
|
| 查看次数: |
1206 次 |
| 最近记录: |