[英]VS2015 Project.json Dependencies in Console app
I have a console app started in VS2015. 我有一个在VS2015中启动的控制台应用程序。 I need three references added to the project, but I can't get all three to be correctly referenced and compiled.
我需要将三个引用添加到项目中,但是无法正确引用和编译所有三个引用。 Here is what I am trying to do:
这是我正在尝试做的事情:
z:\\Documents\\Visual Studio 2015\\Projects\\[solution1]\\console app\\FirstFile.dll z:\\ Documents \\ Visual Studio 2015 \\ Projects \\ [solution1] \\ console app \\ FirstFile.dll
z:\\Documents\\Visual Studio 2015\\Projects\\[solution1]\\console app\\SecondFile.dll z:\\ Documents \\ Visual Studio 2015 \\ Projects \\ [solution1] \\控制台应用程序\\ SecondFile.dll
My project.json file dependencies section now looks like this: 我的project.json文件依赖项部分现在看起来像这样:
"dependencies": { "FirstFile": "1.0.0-*", "SecondFile": "1.0.0-*" }
This works correctly. 这可以正常工作。 I can compile, use the classes in the DLLs and all is well.
我可以编译,使用DLL中的类,一切都很好。
I next needed to add a reference to an EF project that is in a different solution, and in a different solution folder. 接下来,我需要添加对在不同解决方案和不同解决方案文件夹中的EF项目的引用。 In my console solution, I added the EF project from its solution to my console solution using Solution > Add Existing Project.
在控制台解决方案中,我使用解决方案>添加现有项目将EF项目从其解决方案添加到了控制台解决方案中。 I then added a Project Reference to my console app.
然后,我向控制台应用程序添加了项目参考。
The physical layout on my drive looks like this: 驱动器上的物理布局如下所示:
z:\\Documents\\Visual Studio 2015\\Projects\\[solution1]\\[console app project] z:\\ Documents \\ Visual Studio 2015 \\ Projects \\ [solution1] \\ [控制台应用程序项目]
z:\\Documents\\Visual Studio 2015\\Projects\\[solution2]\\[referenced EF project] z:\\ Documents \\ Visual Studio 2015 \\ Projects \\ [solution2] \\ [引用的EF项目]
The console app and the EF project both reference the same .NET framework 4.5.1. 控制台应用程序和EF项目都引用相同的.NET Framework 4.5.1。
After I add the project reference, the dependencies section in the console app project.json file now looks like: 添加项目引用后,控制台应用程序project.json文件中的dependencies部分现在看起来像:
"dependencies": {
"FirstFile": "1.0.0-*",
"EF Project": "1.0.0-*",
"SecondFile": "1.0.0-*"
}
I then run dnu restore. 然后,我运行dnu restore。 It immediately returns error message that it cannot find any of the dependencies:
它立即返回错误消息,表明找不到任何依赖项:
Unable to locate Dependency FirstFile >= 1.0.0-* 无法找到依赖项FirstFile> = 1.0.0- *
Unable to locate Dependency SecondFile >= 1.0.0-* 无法找到依赖项SecondFile> = 1.0.0- *
Unable to locate Dependency EF Project >= 1.0.0-* 无法找到Dependency EF Project> = 1.0.0- *
I added a global.json file with the following source option: 我使用以下源选项添加了global.json文件:
{ "sources":["","Z:\\\\Documents\\\\Visual Studio 2015\\\\Projects\\\\solution2\\\\referenced EF Project"] }
I re-ran the dun restore, but it has the same three cannot find dependencies errors. 我重新运行了dun restore,但是它具有相同的三个找不到依赖项错误。
Any suggestions to get this scenario working? 有什么建议可以使这种情况起作用?
@@ccampj, you should use bin configuration section, here is how to do : @@ ccampj,您应该使用bin配置部分, 这是怎么做的 :
You can create an project that, instead of compiling, references an already compiled dll and generates a package containing that dll.
您可以创建一个项目,而不是进行编译,而是引用一个已编译的dll并生成一个包含该dll的程序包。 To do this you use syntax like this:
为此,您可以使用如下语法:
{
"frameworks" : {
"dnx451" : {
"bin" : { "assembly":"<path to dll>", "pdb" :"<path to pdb if needed>" }
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.