How to create an extern alias for System.Core?

I really need an external alias for System.Core in my project. Unfortunately, in a .Net 4.0 project, you cannot even add a reference to System.Core , since, apparently, the build system includes it by default. Does anyone have an idea on how I can force the system so that I can specify an extern alias for this library? Thanks!

+3
source share
1 answer

This question is old, but I ran into the same problem. As I understand it, this is due to the fact that Visual Studio implicitly adds a link to System.Core.

You can override this by editing the csproj msbuild file and adding:

 <PropertyGroup> <AdditionalExplicitAssemblyReferences/> </PropertyGroup> 

in the end.

This disables any AdditionalExplicitAssemblyReferences that I believe Visual Studio passed to MSBuild using the / p [roperty] switch. Of course, now we still need to add the System.Core link, since it is no longer referenced. Do it by adding

 <Reference Include="System.Core"> <RequiredTargetFramework>3.5</RequiredTargetFramework> <Aliases>global,ActualSystemCore</Aliases> </Reference> 

to an ItemGroup containing links (or new ones).

You can now access the System.Core type using

 ActualSystemCore::System.... 
+3
source

Source: https://habr.com/ru/post/979995/


All Articles