Can I pass the name of VisualStudio Edition through the compiler option?

I use Microsoft.QualityTools.Testing.Fakes to mock some unit tests.

But this assembly is only available to users with VisualStudio Ultimate.

Users of other publications (Professional) cannot create and run this test project, and this gives an error in their environment.

So, I created a compiler directive to handle this:

#define Ultimate

#if Ultimate
using Microsoft.QualityTools.Testing.Fakes;
#endif

And my testing method:

#if Ultimate
    using (ShimsContext.Create())
    {
        ... My code
    }
#else
    Assert.Inconclusive("This test needs VS Ultimate to run");
#endif

This works fine, but the user still needs to comment / uncomment the definition line.

So, is there a way to pass my VS Edition to the compiler? Or is there a different approach?

+4
source share
2 answers

csproj , <PropertyGroup> add:

<PropertyGroup Condition=" $(VisualStudioEdition.Contains('Ultimate')) ">
  <DefineConstants>$(DefineConstants);ULTIMATE</DefineConstants>    
</PropertyGroup>

, , :

#if ULTIMATE

, @Damian:

<PropertyGroup Condition=" $(VisualStudioEdition.Contains('Ultimate')) Or $(VisualStudioEdition.Contains('Enterprise')) ">
  <DefineConstants>$(DefineConstants);ULTIMATE</DefineConstants>    
</PropertyGroup>

, , @Uwe, ""... csproj : -)

+6

@xanatos - , , . .

, ( ), Visual Studio .

, , , .suo( ). , - , .

( , , ), #if s. , .

+2

All Articles