views:

304

answers:

3

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

Is there a way to keep a file in a project but not have the standard SCCI provider attempt to keep checking in the file?

Essentially what we are wanting to do is to create "by developer" code ability similar to how we code in c++, this allows for us to let our developers do nightly check-ins with pseudo code and by-developer utilities.

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


EDIT I don't want to create new configurations in the solution file either, I want these to be as machine specific as possible, without source control bindings to the user on the file/setting.

+1  A: 

MSBuild has Conditional Constructs. All you have to do is modify the Solution file to include what you want. The end result would look very similar to your example code.

<When Condition=" '$(Configuration)'=='TOM' ">
  <ItemGroup>
     <Compile Include="tomCode\*.cs" />     
   </ItemGroup>
</When>
I couldn't get this to work.
Tom Anderson
Thanks for spurring my idea :)
Tom Anderson
A: 

I am currently trying this.

  <ItemGroup Condition=" '$(Configuration)' == 'Tom'">
    <Compile Include="Tom.cs" />
  </ItemGroup>
Tom Anderson
*Note: This still requires you to check-in the file, but it does work with the #if (TOM) not compiling the class.
Tom Anderson
+1  A: 

Well, it seems after working off the post here, and literally trying "wierd" things, I had an idea.

Essentially I used the *.csproj.user file, declared a UserConfig property, added a new Constant (for code checks), and did an ItemGroup with the condition of the UserConfig. All this fell under the DEBUG flag.

The only issue is that the file does not show up in the solution explorer, but in c++ they didn't either.

My *.csproj.user file

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt;
  <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>

Resulting Code

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