2016-05-20 45 views
6

Sto cercando di aggiornare i miei progetti RC1 ASP.NET 5 ai progetti ASP.NET Core RC2. Sto avendo alcuni problemi perché sto usando librerie che non supportano ancora .NET Core, quindi devo correre sul framework completo. Questo ha funzionato bene in RC1, ma non sono in grado di capire il modo giusto per ottenere questo risultato in RC2.Utilizzo di librerie net451 in un'applicazione ASP.NET Core (RC2)

Ho una libreria di classi che può ripristinare i pacchetti e creare correttamente. E ho un progetto di test che fa riferimento alla libreria di classi. Quando provo a costruire il progetto di test, sto ottenendo i seguenti errori:

> 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. 

I file project.json per questi due progetti simile a questa:

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" 
     ] 
    } 
    } 
} 

Come devo configurarlo correttamente per utilizzare le librerie net451 nella mia app?

risposta

2

Il mscorlib dipendenza non può essere risolto

mi sono imbattuto in questo stesso problema di ieri. Il problema è che il project.json per il progetto di prova ha come target il netcoreapp1.0. Invece puoi scegliere come target il framework net451 come il servizio che stai testando e che dovrebbe "funzionare".

{ 
    "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": { } 
    } 
} 

Per maggiori dettagli su questa verifica il Migrating from ASP.NET 5 RC1 to ASP.NET Core. Un'altra grande risorsa è il file markdown sullo corefx repo che specifica lo standard della piattaforma .NET .

+1

Questo in realtà risponde alla domanda su come utilizzare le librerie net451 in un'applicazione ASP.NET Core (RC2)? A meno che non sia fondamentalmente frainteso, sembra che questa risposta suggerisca di utilizzare invece le librerie net451 nelle applicazioni net451. –

Problemi correlati