How do I create compiled custom files in Visual Studio 2008?

In C ++ you can compile files that are not included in the solution, with C # this is not the case.

Is there a way to keep the file in the project but don't want the standard SCCI provider to keep checking the file?

Basically, we want to create a "developer" ability, similar to how we code in C ++, this allows us to allow our developers to do nightly checks with pseudocode and developer tools.

#ifdef (TOM)
#include "Tom.h";
#endif

      


EDIT I also don't want to create new configurations in the solution file, I want them to be as machine specific as possible, without linking the source to the user in the file / setting.

+1


source to share


3 answers


Well, it looks like after practicing a job here, and literally trying "weird" things, I got an idea.

Basically, I used a * .csproj.user file, declared a UserConfig property, added a new constant (for code validation) and made an ItemGroup with a UserConfig condition. All of this fell under the DEBUG flag.

The only problem is that the file doesn't show up in the solution explorer, but they weren't in C ++ either.

My file * .csproj.user



<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <UserConfig>Tom</UserConfig>
    <DefineConstants>DEBUG;TRACE;TOM</DefineConstants>
  </PropertyGroup>
  <ItemGroup Condition=" '$(UserConfig)' == 'Tom'">
    <Compile Include="Tom.cs" />
  </ItemGroup>
</Project>

      

Result code

#if (TOM)
            Tom t = new Tom();
#endif

      

+1


source


MSBuild has conditionals . All you have to do is modify the solution file to include what you want. The end result will be very similar to your example code.



<When Condition=" '$(Configuration)'=='TOM' ">
  <ItemGroup>
     <Compile Include="tomCode\*.cs" />     
   </ItemGroup>
</When>

      

+1


source


I am currently trying to do this.

  <ItemGroup Condition=" '$(Configuration)' == 'Tom'">
    <Compile Include="Tom.cs" />
  </ItemGroup>

      

0


source







All Articles