1

The project that I've cloned locally uses the following dependencies:

<TargetFrameworks>netstandard2.0;MonoAndroid10.0;Xamarin.iOS10;Xamarin.Mac20;netcoreapp3.0;netcoreapp3.1;net40;net45;net46;net47;net48</TargetFrameworks>

I need to tell Visual Studio to ignore those frameworks and projects<->frameworks dependencies that aren't installed in my system and build only existing ones without manually deleting them from the whole solution and every project in the solution, without installing them and setting up. Let's say build .sln projects with netcoreapp3.1 if it's installed.

Is there a way to do this?

4
  • 'build .sln projects with netcoreapp3.1 if it's installed.' and what should happen if both netcoreapp33.1 and netstandard2.0 are installed? In any case you will probably have to change all projects, because the logic for conditionally selecting the framework is going to have to be in the projects. Commented Jan 18, 2022 at 8:35
  • @stijn, a huge amount of target frameworks result in a huge amount of errors that these project dependencies produce, but still the github authors tend to implement as much as they possibly can, especially if their repository has a nuget package integration. Forking one results in an error chaos. Commented Jan 18, 2022 at 19:48
  • 1
    I understand, but that does not answer my question; I'll rephrase: do you just want to be able to build for a specific framework, no matter how, or is it really so that you want msbuild to figure out automatically which framework(s) is/are installed and use that (and if yes: what should happen exactly if in fact you have multiple frameworks installed)? Thing is, answer to the first question could be simple, as in msbuild my.sln /p:TargetFramework=xxx will use xxx no matter what. The answer to the second is complicated probably. Commented Jan 19, 2022 at 8:31
  • stijn, your answer to the first one answers my question. Commented Jan 19, 2022 at 8:44

1 Answer 1

3

See documentation on TargetFrameworks: it is ignored when TargetFramework (singular) is specified hence you can build with the framework of choice using

msbuild my.sln /p:TargetFramework=netcoreapp3.1

(argueably, just specifying a bunch of possible frameworks hardcoded in the project files is not super user-friendly, would be better if the authors did that conditionally somehow)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.