7
我已经从.NET4.0 DLL创建了一个NuGet包,其中包含混合(托管和本机)代码。NuGet包依赖于Visual C++ 2013运行时
本机代码封装起来.NET4.0 DLL内,但对Visual C++ 2013 Redistributable
依赖我想头脑风暴的方式要么一起打包NuGet包的REDIST和/或向用户发出警告他们需要它,但我正在画空白。
任何人有任何想法?
我已经从.NET4.0 DLL创建了一个NuGet包,其中包含混合(托管和本机)代码。NuGet包依赖于Visual C++ 2013运行时
本机代码封装起来.NET4.0 DLL内,但对Visual C++ 2013 Redistributable
依赖我想头脑风暴的方式要么一起打包NuGet包的REDIST和/或向用户发出警告他们需要它,但我正在画空白。
任何人有任何想法?
我其实自己很好解决了这个问题。虽然我找不到解决方案将VCpp运行时作为依赖项包含在NuGet包中,但我确实找到了一种解决方案,警告用户需要Visual C++ 2013 Runtime。
我运行这段代码一次,静态,在组件/库需要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");
}
}
这应该提醒正在消耗你的NuGet包,他们需要安装运行任何开发商。
相当令人怀疑,隐藏这是一个好主意。它不仅仅是CRT,这很容易解决,你也对客户项目的平台目标设置有着坚定的依赖。如果你没有一个纯粹的包装,很难隐藏。基本的建议[在这篇文章中](http://stackoverflow.com/a/28771413/17034)。 –
我不一定要隐藏,但我至少要告知。否则,我会通过'Y U NO Work'类型的问题向用户提供技术支持 –