2016-05-20 14 views
6

Próbuję uaktualnić moje projekty ASP.NET 5 RC1 do projektów Core2 z programu ASP.NET Core. Mam pewne problemy, ponieważ korzystam z bibliotek, które jeszcze nie obsługują .NET Core, więc muszę uruchomić na pełnej strukturze. To zadziałało dobrze w RC1, ale nie jestem w stanie znaleźć odpowiedniego sposobu na osiągnięcie tego w RC2.Używanie bibliotek Net451 w aplikacji ASP.NET Core (RC2)

Mam jedną bibliotekę klas, która może przywracać pakiety i poprawnie budować. Mam projekt testowy odwołujący się do biblioteki klas. Kiedy próbuję zbudować projekt testowy, Dostaję następujące błędy:

> dotnet build 
Project TenantService (.NETFramework,Version=v4.5.1) was previously compiled. Skipping compilation. 
Project TenantServiceTests (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing 
Compiling TenantServiceTests for .NETCoreApp,Version=v1.0 
C:\projects\TenantService\test\TenantServiceTests\project.json(25,23): error NU1001: The dependency mscorlib could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency mscorlib could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(25,23): error NU1001: The dependency mscorlib could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency mscorlib could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(26,21): error NU1001: The dependency System could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(26,21): error NU1001: The dependency System could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(27,26): error NU1001: The dependency System.Core could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System.Core could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(27,26): error NU1001: The dependency System.Core could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency System.Core could not be resolved. 
C:\projects\TenantService\test\TenantServiceTests\project.json(9,31): error NU1001: The dependency Microsoft.CSharp could not be resolved. 

Pliki project.json dla tych dwóch projektów wyglądać następująco:

src \ TenantService \ project.json

{ 
    "version": "1.0.0-*", 

    "dependencies": { 
    "NETStandard.Library": "1.5.0-rc2-24027", 
    "Microsoft.Extensions.Options": "1.0.0-rc2-final", 
    "Newtonsoft.Json": "8.0.4-beta1", 
    "MongoDB.Driver": "2.2.4", 
    "StackExchange.Redis": "1.1.603" 
    }, 

    "frameworks": { 
    "net451": {} 
    } 
} 

Test \ TenantServiceTests \ project.json

{ 
    "version": "1.0.0-*", 
    "testrunner": "xunit", 
    "description": "TenantServiceTests Class Library", 
    "authors": [ "Henning" ], 

    "dependencies": { 
    "xunit": "2.1.0", 
    "TenantService": "1.0.0-*", 
    "dotnet-test-xunit": "1.0.0-rc2-build10015" 
    }, 

    "frameworks": { 
    "netcoreapp1.0": { 
     "dependencies": { 
     "Microsoft.NETCore.App": { 
      "type": "platform", 
      "version": "1.0.0-rc2-3002702" 
     } 
     }, 
     "imports": [ 
     "net451" 
     ] 
    } 
    } 
} 

W jaki sposób powinienem poprawnie ustawić tę opcję, aby korzystać z bibliotek Net451 w mojej aplikacji?

Odpowiedz

2

mscorlib zależność nie może być rozwiązany

wpadłem na ten sam problem wczoraj. Problem polega na tym, że project.json dla projektu testowego jest kierowany na netcoreapp1.0. Zamiast tego możesz kierować na strukturę net451, taką jak usługa, z którą testujesz, i która powinna "po prostu działać".

{ 
    "version": "1.0.0-*", 
    "testrunner": "xunit", 
    "description": "TenantServiceTests Class Library", 
    "authors": [ "Henning" ], 

    "dependencies": { 
    "xunit": "2.1.0", 
    "TenantService": "1.0.0-*", 
    "dotnet-test-xunit": "1.0.0-rc2-build10015" 
    }, 

    "frameworks": { 
    "net451": { } 
    } 
} 

Aby uzyskać więcej informacji na temat tej kasy Migrating from ASP.NET 5 RC1 to ASP.NET Core. Kolejnym świetnym zasobem jest plik przeceny na urządzeniu corefx repo, który zawiera szczegółowe informacje na temat platformy .NET Platform Standard.

+1

Czy to naprawdę odpowiada na pytanie, jak korzystać z bibliotek net451 w aplikacji ASP.NET Core (RC2)? Chyba że coś zasadniczo nie rozumiem, wygląda na to, że ta odpowiedź sugeruje, że zamiast tego używasz bibliotek net451 w aplikacjach net451. –

Powiązane problemy