I'm getting build errors because some classes I'm using are available in "DNX 4.5.1" and not "DNX Core 5.0".
The error is:
The type or namespace '[someclass]' could not be found.
In the project column of the "Error List" window, I see DNX Core 5.0.
In the context menu, DNX 4.5.1 is selected. Why does VS.NET try to keep using DNX Core 5.0 when the context is 4.5.1?
In case some people are still struggling with this, you can dereference the DNX Core 5.0 by removing it from your framework references in the project.json file.
The section
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
Should become
"frameworks": {
"dnx451": { }
},
Rather than completely removing DNXCORE50 from your project.json. As before, you can add framework specific code if you wrap it in #if #endif as shown in the code below. The framework names DNX451 and DNXCORE50 are well known symbols actually referred to as target framework monikers (TFMs) and are the same throughout the project.json file, folder names, NuGet packages etc.
Simply apply a conditional statement:
public string Index(){
#if DNX451
//code logic here for DNX 4.5.1
#endif
#if DNXCORE50
//code logic here for DNX Core 5.0
#endif
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With