Closed zemstaspamera closed 4 years ago
@Pilchie I assume this is a question for your team.
@zemstaspamera we do hope to enable this scenario but with the current VS tools it is a little rough.
I've build a way to do that. Check out: https://github.com/manu-silicon/corefxref. It will enable you to compile against the relatively recent version of CoreFX reference assemblies. However I'm not sure if you will be able to mix this with WPF as WPF may rely on APIs not yet present in CoreFX.
I think there are a couple of different things here that are being conflated:
frameworks
section of the project.json. It's perfectly fine to set it to something like net46
to target the .NET Framework, version 4.6, and use WPF. NOTE however, that this means you are NOT targeting .NET Core, and your won't support running cross platform on Linux, OSX, etc. NOTE Also, that this means that you can't upgrade .NET packages that contain types that are part of .NET 4.6, since they will be resolved from the GAC at runtime. If you can use only code that is supported in .NET Core, then we'd recommend using one of the netstandard
versions described here, with the unfortunate caveat that they aren't supported quite yet, but they should be in the next release of the .NET Core tools.netstandard
using project.json/xproj, and then have desktop specific apps built on top of them using .csproj for WPF, etc.Hope this helps. @davidfowl - anything I've missed?
@Pilchie,
The ability to reference a project.json/xproj project from a .csproj project.
It is possible now via nuget package created from xproj, but only when You do not have the xproj and csproj project folder in the same parent folder or solution, because then "project reference to xproj" wins over "nuget package reference to xproj" and it cannot be overriden by let us say type
attribute of the dependency in project.json
.
Or is there a way to do it somehow?
When will be the next release of .NET Core tools (CLI?) released?
How soon until I can reference an xproj project in the same solution as a full framework csproj? Is that going to be part of the xproj -> csproj msbuild work?
It's a big holdup to even getting started with .NET Core. Xproj is the only option at the moment because the core library needs multi-targeting. (ECDsaCng
has been available on full framework since .NET 3.5 but isn't available until netstandard1.4
, and the top-level GUI client is required to be net452
which restricts me to netstandard1.2
so I can't use a single-target netstandard1.4
PCL csproj. If I understand correctly, the only option for ECDsaCng
is to target netstandard1.4
and net45
separately.)
Tagging @davkean and @srivatsn.
Yes, once .NET Core projects are csproj based then you should be able to reference them from a full framework csproj. That work is being tracked by https://github.com/dotnet/roslyn-project-system/issues/282
We recently added this document which describes how you can set up cspoj's now to accomplish what you want. Keep in mind that it's fairly manual and easy to mess up right now.
@mellinoe Slightly confused- which project gets this edit? The multi-target xproj class library or the full framework csproj winforms app? Surely I'm not modifying the full framework csproj to use dotnet.exe
? But if I'm modifying the multi-target DLL xproj by changing it to a csproj and following this document, why would I add a StartAction?
For a class library, use the instructions at the top of the document. The StartAction
stuff would just be for Exe projects, so not applicable in your case. And, yes, you wouldn't be modifying your .NET framework project, except potentially to make it use project.json for dependencies.
The instructions at the top of the document don't seem to address the scenario where I need to target both netstandard1.4
and net45
. They instruct me to create a new PSL csproj, but I don't see where it gets converted from single-target to multi-target. Like I said, I need ECDsaCng
in the class library whether I'm using it with a core app or a full framework 4.5.2 app. Am I wrong in thinking that a single target project is not an option and that the class library needs to be xproj for multi-target? In which case I can't use csproj?
In your case, you would probably end up having two csproj's, one for each configuration (net452, netstandard1.4). You could share common includes in a shared build file as well, if you wanted. Technically you could combine them into one file, but it would probably quickly get messy and would require lots of manual fiddling with project configurations.
This probably isn't buying you much in your particular case since you need to specifically target net452.
I don't mind hacking a csproj and eschewing tooling, but maintaining two project file lists is unappealing. I'll wait then until I'm able to target both netstandard1.4 and net45 in a single csproj.
is that feature (multi-targeting from a csproj with tooling support) planned? seems a bit different to the original question of csproj->xproj references. of course it'd be great to have both.
Well xproj is going away entirely, right? And multi-targeting isn't, so it would end up in csproj, right?
Yes it's tracked here - https://github.com/dotnet/roslyn-project-system/issues/190
excellent
Closing, it does not look like there is anything left for corefx discussion. Work is tracked in Roslyn.
Hello,
Is there any way to reference project created with .NET Core (dnxcore50 and dnx451) to regular C# project, for example WPF? I found a proposition.which probably allows me to do what I want. However, is referencing a "net46" framework a good solution? I have not seen that before.
I'm asking because I preparing a strategy for API for corporate services based on Desktop apps and I would like to make it available also on Linux.
Thanks for help.