从ASP.NET核心项目

时间:2016-07-15 18:15:05

标签: .net asp.net-core-mvc .net-core asp.net-core-1.0 project.json

我有一个在.NET 3.5下编译的DLL,它代表一个POCO数据模型。客户端应用程序仅限于.NET 3.5,并且DLL必须由客户端和服务器共享,因此不能重新编译DLL。

我正在尝试将服务器REST API重写为ASP.NET核心MVC项目(使用VS2015下的1.0版本和预览2工具)。我尝试使用所谓的“bin语法”更新project.json,如下所示,但是包恢复日志显示了一堆错误,例如:

  

错误:包Microsoft.NETCore.App 1.0.0与。不兼容   net35(.NETFramework,Version = v3.5)。打包Microsoft.NETCore.App   1.0.0支持:netcoreapp1.0(.NETCoreApp,Version = v1.0)

"frameworks": {
"netcoreapp1.0": {
    "imports": [ "dotnet5.6", "portable-net45+win8" ]
},
"net35": {
    "bin": { "assembly": "c:\\source\\externaldllsdebug\\datadef.dll" }
}

我还尝试在DLL文件夹中设置nuget包,然后使该文件夹成为新的nuget源。它打开包很好但是在尝试导入DLL时失败了。

1 个答案:

答案 0 :(得分:1)

我不认为你现在想要做什么。

另一种解决方案是重构生成共享DLL的项目,以生成一个与.NET 3.5和"frameworks": { "net35": { }, "netstandard1.1": { "dependencies": { "NETStandard.Library": "1.6.0" } } } 兼容的库:

 <?php
$counter = 'apk/counter.txt'; // text file to store download count - create manually and put a 0 (zero) in it to begin the count
$download = 'http://site.my/apk/file.apk'; // the link to your download file
$number = file_get_contents($counter); // read count file
$number++; // increment count by 1
$fh = fopen($counter, 'w'); // open count file for writing
fwrite($fh, $number); // write new count to count file
fclose($fh); // close count file
header('Location: $download'); // get download
?> 

这样,您可以生成一个仍然在.NET 3.5项目中工作的DLL,也可以生成一个可以安装在ASP.NET Core项目中而没有任何问题或黑客攻击的DLL。