How to Reference .xproj into .csproj?

冷暖自知 提交于 2019-12-03 10:06:59

It is not possible to reference a xproj from a csproj directly.

You have 2 possible solutions for this.

A) Deploy the xproj as a NuGet package and use the NuGet package in your csproj.

B) Convert your csproj to a xproj.

Note: the xproj must support your used .NET csproj. net451 etc.

Here's an example of a csproj referencing a xproj NuGet package

https://github.com/damienbod/ElasticsearchCRUD/tree/master/samples/ConsoleElasticsearchCrudExample

XProj is dead. Use a portable class library (csproj) and then set it to .NET Standard and the level you want to use for compatibility. Then project.json will be created (which will likely be renamed later) and csproj will still be there thus making adding the reference easy and it just works.

If you need cross compatibility the only way to do so is to do the above, and then add an existing project in the case of the .NET core solution and choose the project.json file instead of the .csproj. This will create the xproj as well. However note that the xproj/project.json will support multi-targeting but the .csproj will not and you'll break the UI for project properties if you try. (it still works but the UI is dead)

Your only other alternative is to bind to the dll not the project. You can use an xproj, put in the targets and then Add references and choose the dll with browse.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!