core icon indicating copy to clipboard operation
core copied to clipboard

C++/CLI targeting .net core (.net 6)

Open HKunogi opened this issue 5 years ago • 17 comments

When trying to make a new c++/cli project to target .net core instead of .net framework, or when changing an existing project to target it, it gives error when applying the setting. I've tried all different possible configurations on the project and it keeps on the same problem, I just cannot target the .net core on it. image

HKunogi avatar Mar 14 '21 12:03 HKunogi

@jkoritzinsky can you help with this?

antonfirsov avatar Mar 15 '21 16:03 antonfirsov

Does this occur with any .NET project or just C++/CLI?

jkoritzinsky avatar Mar 15 '21 16:03 jkoritzinsky

Does this occur with any .NET project or just C++/CLI?

This only happens when i try building an C++/CLI using netcore, if i use net framework it goes fine, and if i try to use c# it also goes fine.

HKunogi avatar Mar 15 '21 22:03 HKunogi

I'm not sure why the correct MSBuild files aren't being included.

@wli3 can you tag the C++ project system on this issue so they can take a look?

jkoritzinsky avatar Mar 16 '21 00:03 jkoritzinsky

@olgaark

wli3 avatar Mar 19 '21 23:03 wli3

Apparently, Microsoft.NET.ILLink.targets are using a property for the task location which is not defined in vcxproj, which imports common msbuild props/targets, but not c# ones. Run msbuild /pp on a c# project to see where this property is defined.

olgaark avatar Mar 19 '21 23:03 olgaark

@agocke

wli3 avatar Mar 20 '21 03:03 wli3

up up.

snikeguo avatar May 07 '21 09:05 snikeguo

This was probably fixed by https://github.com/dotnet/sdk/issues/16725

@HKunogi Can you try pulling a copy of the Preview 4 SDK from https://github.com/dotnet/installer and try your scenario again? Preview 4 should be available very soon.

@olgaark It looks like the root cause is the SDK targets are imported, but not the props. https://github.com/dotnet/sdk/issues/16725#issuecomment-813456887 Is there a particular reason for this? Importing the targets and not the props is likely to cause these types of failures.

agocke avatar May 07 '21 18:05 agocke

VC projects are importing what SDK people told us to import, I don't know the reason. If we need to import more, just let us know.

olgaark avatar May 07 '21 19:05 olgaark

@sbomer, who originally found the difference @wli3 Can you elaborate on why the guidance would be to import one and not the other?

agocke avatar May 07 '21 20:05 agocke

C++/CLI does not support nuget restore yet. So any props and target require that to work will not be imported. You can try to add that to part of the import (search for '$(Language)' != 'C++') and then test. If it works you start to include that props or targets.

wli3 avatar May 10 '21 17:05 wli3

any updates?! it seems VS2022 C++ clr can't target .net 6

kzhui125 avatar Apr 16 '22 15:04 kzhui125

.net 5 End of support is May 08, 2022

but now VS 2022 C++ clr still doesn't support .NET 6!!!!!!

kzhui125 avatar Apr 16 '22 15:04 kzhui125

1

There is only .net core 3.1 and .net 5, still no .net 6 support now!!

kzhui125 avatar Apr 16 '22 15:04 kzhui125

This issue was previously describing a problem with C++/CLI colliding with the ILLink targets. That issue is now fixed. This appears to be a different problem. I'm opening a new issue for it.

agocke avatar Apr 18 '22 07:04 agocke

Actually, this appears to be specific to Visual Studio -- please open a VS feedback issue if you are having issues with Visual Studio.

agocke avatar Apr 18 '22 07:04 agocke