2014-12-30 3 views
1

기존 솔루션을 ASP.NET vNext로 이동하는 중입니다. 내 솔루션은 전통적인 N 계층 응용 프로그램입니다. 이를 염두에두고이 솔루션에는 네 가지 프로젝트가 있습니다. 그 네 개의 프로젝트는 다음과 같이 구성되어 있습니다 요컨대ASP.NET vNext로 솔루션 이동 - 어셈블리를 참조 할 수 없습니다.

/backend 
    /library 
    Sample.cs 
    project.json 
    /web 
    project.json 
/test 
    /library 
    SampleTest.cs 
    project.json 
    /web 
    project.json 
global.json 

web 프로젝트는 library 프로젝트를 참조합니다. /test/library/ 프로젝트는 library 프로젝트를 테스트하기위한 것입니다. /test/web/ 프로젝트는 web 프로젝트를 테스트하기위한 것입니다. 내 문제는 내 test 프로젝트에서 library 프로젝트를 참조 할 수없는 것입니다. 내가 library의 클래스를 참조하려고하면, 나는 말한다 오류 얻을 : 여기

System.IO.FileLoadException: Could not load file or assembly 'library' or one of 
its dependencies. General Exception (Exception from HRESULT: 0x80131500) 
System.IO.FileLoadException: Could not load file or assembly 'library' or one of 
its dependencies. General Exception (Exception from HRESULT: 0x80131500) 
File name: 'library' ---> Microsoft.Framework.Runtime.Roslyn.RoslynCompilationEx 
ception: C:\Projects\MySolution\test\library\SampleTest.cs(21,7 
): error CS0246: The type or namespace name 'Sample' could not be found (
are you missing a using directive or an assembly reference?) 

내 관련 파일의 내용입니다을

/backend/library/project.json

{ 
    "version":"3.0.0.0", 
    "description":"This is the app library", 
    "compilationOptions": { 
    "warningsAsErrors": true 
    }, 
    "dependencies": { 
    "Microsoft.Data.Common":"0.1.0.0-alpha-build-0137" 
    }, 
    "code": [ "**\\*.cs", "..\\Shared\\*.cs" ], 
    "frameworks": { 
    "net45": {} 
    } 
} 

/backend/library/Sample.cs

using System; 
using System.Collections.Generic; 

using System.Data; 
using System.Data.Common; 
using System.Data.SqlClient; 

using System.Linq; 
using System.Text; 

namespace MySolution.Library 
{ 
    public class Sample 
    { 
    public int Id { get; set; } 
    public string Name { get; set; } 

    public void Save() 
    { 
    } 
    } 
} 

/test/library/project.json

{ 
    "commands": { 
    "test": "Xunit.KRunner" 
    }, 
    "dependencies": { 
    "Xunit.KRunner": "1.0.0-beta1" 
    }, 
    "frameworks": { 
    "aspnet50": { }, 
    "aspnetcore50": { } 
    } 
} 

/test/library/SampleTest.cs

using System.IO; 
using Microsoft.Framework.Runtime; 
using Xunit; 

namespace MySolution.Library 
{ 
    public class SampleTest 
    { 
    [Fact] 
    public void Save() 
    { 
     Sample sample = new Sample(); 
     sample.Save(); 
     Assert.NotNull(sample); 
    } 
    } 
} 

global.json

{ 
    "sources": [ "backend/library" ] 
} 

무엇 내가 틀렸어? 내 test 프로젝트에서 내 library 프로젝트를 참조 할 수없는 이유는 무엇입니까?

감사합니다.

답변

0
  1. global.json 변화에서이 sources 당신은 테스트 프로젝트에서 library 참조 누락
  2. ["backend","test"]에 :

    "dependencies": { 
        "library": "", 
        "Xunit.KRunner": "1.0.0-beta1" 
    }, 
    
+0

나는'테스트 \ 라이브러리 \에'library'를 추가하는 경우 project.json '파일에서 # 2와 같이 오류가 발생합니다. 'kpm restore'를 실행하면 다음과 같은 에러가 발생합니다 :'TODO : 순환 의존 관계 참조가 지원되지 않습니다. 패키지 '도서관'.' 테스트를 실행하면 '프로세스가 StackOverflowException으로 종료되었습니다.'라는 오류 메시지가 나타납니다. – user70192

+0

다른 문제를 제외하기 위해 테스트 프로젝트의 이름을 다른 것으로 바꿀 수 있습니까? 'library.test'와 비슷합니다. –

+0

bravo !. 나는'/ test/library' 디렉토리의 이름을'test/library-tests'로 변경했습니다. 그것은 해킹처럼 느껴집니다. 그러나 그것은 작동합니다. 도와 줘서 고마워! – user70192