문제 설명
ASP.NET 5 ‑ 프로젝트의 파일 참조(csproj와 유사한 참조 누락) (ASP.NET 5 ‑ Referencing files in projects (missing csproj‑like references))
저는 Visual Studio 2015를 사용하여 ASP.NET 5 앱을 개발 중입니다. 하나의 솔루션에서 여러 프로젝트를 작업하는 등 RC1 이후로는 전혀 문제가 없습니다.
하지만 며칠 동안 VS Code로 작업해야 하는데 수업 누락 문제를 해결하는 방법을 잘 모르겠습니다. 프로젝트 A와 프로젝트 B에 대한 솔루션이 있다고 가정 해 봅시다. 내부에 자체 클래스가 있습니다. 이전 버전의 ASP.NET에서는 모든 파일이 .csproj 파일에서 참조되었지만 지금은 .xproj 파일이 거의 비어 있습니다. 파일에 대한 직접 경로는 없습니다. 그리고 내 프로젝트 A에서 새 클래스를 만들었습니다. 모든 올바른 네임스페이스가 있고 프로젝트 B에는 A에 대한 참조가 있습니다(프로젝트 B의 컨트롤러도 동일한 A의 네임스페이스에서 클래스를 사용합니다!). 그러나 컴파일 오류가 있습니다. 프로젝트 A에서 내 수업을 찾을 수 없습니다 :/
VS Code를 사용하면 새 파일에 대해 컴파일러에 알리기 위해 프로젝트에 일종의 참조를 추가해야 한다고 생각했지만 올바른 위치를 찾을 수 없습니다. 어떤 아이디어가 있습니까?
참조 솔루션
방법 1:
You do this in the project.json file.
{
"dependencies": {
"ProjectA": "1.0.0‑*"
}
}
You declare the dependency. If the source is available in the solution folder, it will find it and use it. If the source isn't available, it can pull down a NuGet package that matches the version number. The documentation I linked to above provides more information about this process.
Once you have a dependency registered, you can refer to the public classes in your project. You'll need to fully qualify the dependencies (use the full namespace) or add a using <namespace>
directive at the top of your file.