Can I specify SDK version in .csproj instead of global.json?

Hello .Net Foundation Forum

I’m trying to add a new .net core 3.x project into our git repo, however, this repo is quite large and has .netcore 2.x specified in a root global.json, I understand I can override it by adding a new global.json with .netcore 3.x in my project to override, however, things are a bit tricky.

As you can see below, my folder and other projects share the same folder1, if I put global.json (3.x) in folder1, other projects will break because they have 2.x compatible csproj, if I put global.json (3.x) in myfolder, if I run msbuild from root or folder1, globaljson is not taking any effect, because global.json(3.x) in myfolder is not the current working dir. If I run build from myfolder with global.json(3.x) in it, it works fine. The problem here is our devops build does not build from myfolder, instead it builds from root or folder1, so I don’t really have a choice where to put global.json(3.x).

Can I specify the toolchain inside my csproj? or from a global.json, can I specify a specific version for a specific subfolder?

root
–global.json (.netcore 2.x)
–folder1
----other projects
----myfolder
------global.json (.netcore 3.x)

Thanks
Chandler.

So you’re basically asking for the 2.x toolchain to invoke the 3.x toolchain for one specific project? I don’t think anything like that exists.

Though: are you sure you can’t specify 3.x in the folder1 (or root) folder? The SDKs should generally be backwards compatible and the 3.x toolchain is able to build 2.x projects. If you actually tried it and it didn’t work, what were the errors you got?

.NET Foundation Website | Blog | Projects | Code of Conduct