[英]Referencing .NET Standard csproj project from .NET Framework traditional project
I have a library written against .NET Standard 1.3 which should be compatible with the .NET Framework 4.6.1 runtime. 我有一个针对.NET Standard 1.3编写的库,它应该与.NET Framework 4.6.1运行时兼容。 The library uses the new csproj and works fine when referenced by .NET Core projects.
该库使用新的csproj,并且在.NET Core项目引用时工作正常。
I also have a WPF project on a traditional csproj which should be able to use this library. 我还在传统的csproj上有一个WPF项目,它应该可以使用这个库。 In Visual Studio 2017 I managed to reference the .NET Standard library and it compiles without errors.
在Visual Studio 2017中,我设法引用了.NET标准库,它编译时没有错误。
At runtime, it tries to load assemblies which are dependencies of the .NET Standard project and it fails with assembly not found
exceptions. 在运行时,它尝试加载与.NET Standard项目的依赖关系的程序集,并且在程序
assembly not found
异常时失败。 And I can see that my output folder doesn't have any of the dependencies indeed. 我可以看到我的输出文件夹确实没有任何依赖项。
Is there a way to reference my library in such a way all the required dependencies are copied to the output folder (or an equivalent solution to make the WPF project run fine)? 有没有办法以这种方式引用我的库所有必需的依赖项被复制到输出文件夹(或一个等效的解决方案,使WPF项目运行正常)?
Note: If I reference manually one by one all the missing dependencies and use runtime assembly version binding I can make it run, but I shouldn't really do this when referencing a project. 注意:如果我逐个手动引用所有缺少的依赖项并使用运行时程序集版本绑定我可以使它运行,但在引用项目时我不应该这样做。
This is the full project page: https://github.com/UnoSD/PasswordManager 这是完整的项目页面: https : //github.com/UnoSD/PasswordManager
.NET Standard csproj .NET标准csproj
WPF package.config WPF package.config
It currently is a Roslyn problem: GitHub issue 它目前是一个Roslyn问题: GitHub问题
It is an active issue on Roslyn : 这是Roslyn的一个活跃问题:
https://github.com/dotnet/roslyn/issues/17639 https://github.com/dotnet/roslyn/issues/17639
https://github.com/NuGet/Home/issues/4488 https://github.com/NuGet/Home/issues/4488
You have to specify compiler output for .NET 4.6.1 您必须为.NET 4.6.1指定编译器输出
Put line like below into your csproj in your .NET Standard library project. 将下面的行放入.NET标准库项目的csproj中。
<TargetFrameworks>netstandard1.4;net461</TargetFrameworks>
(that should go instead <TargetFramework>netstandard1.4</TargetFramework>
) (应该改为
<TargetFramework>netstandard1.4</TargetFramework>
)
Build will produce binaries both for .NET 4.6.1 and .NET Core runtime compatible with NET Standard 1.4. Build将为.NET 4.6.1和与.NET Standard 1.4兼容的.NET Core运行时生成二进制文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.