Question

I absolutely need an extern alias for System.Core in my project. Unfortunately, in a .Net 4.0 project, you cannot even add a reference to System.Core because, apparently, the build system includes it by default. Does anyone have any idea on how I can coerce the system to let me specify an extern alias for this lib? Thanks!

Was it helpful?

Solution

This question is old but I ran into the same problem. As far as I understood, this is due to Visual Studio implicitly adding a reference to System.Core.

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

<PropertyGroup>
   <AdditionalExplicitAssemblyReferences/>
</PropertyGroup>

at the end.

This disables any AdditionalExplicitAssemblyReferences that I assume Visual Studio has passed to MSBuild using the /p[roperty] switch. Of course, we now still have to add the System.Core reference as it is no longer referenced. Do so by adding

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

to the ItemGroup that contains references (or a new one).

You can now refer to a System.Core type using

ActualSystemCore::System....
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top