Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Reference .xproj into .csproj?

I have .csproj project and I want to reference other project that is .xproj, everything looks fine but when I try to build solution then I cannot because the .dll is missing. When i reference the .dll from \bin\release\net452\... itself then everything is ok. How to fix that?

EDIT: I am not looking for workarounds - now I am using gulp with gulp.move(). It works fine but it feels dirty...

like image 608
Sebastian 506563 Avatar asked Jul 14 '16 08:07

Sebastian 506563


2 Answers

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

like image 77
Damienbod Avatar answered Nov 08 '22 06:11

Damienbod


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.

like image 32
James Hancock Avatar answered Nov 08 '22 06:11

James Hancock