The first point can be solved with a simple text editor that can process several files at once and find / replace. Just open all your csprojs and replace the line <Compile Include="Properties\AssemblyInfo.cs" /> with
<Compile Include="..\SharedAssemblyInfo.cs"> <Link>Properties\SharedAssemblyInfo.cs</Link> </Compile>
Alternatively, you can write such a utility:
var files = Directory.GetFiles(yourSolutionDir, "*.csproj", SearchOption.AllDirectories); foreach (var f in files) { string contents = File.ReadAllText(f); string result = contents.Replace("<Compile Include=\"Properties\\AssemblyInfo.cs\" />", putSecondStringHere_ItIsJustTooLong);
Regarding the second question ... You can take a look at Visual Studio Custom Project Templates , but I'm not sure if it is worth the effort. You should write a test message that will check this instead. It will be much easier, and the result will not change much.
UPD: About writing tests to validate decision / project files against some custom rules. In principle, the sln / csproj format is simple enough so that it can be analyzed without much effort. Therefore, if you want to link SharedAssemblyInfo.cs in each project - just analyze csproj and check it out. Then put this check on your assembly server and run it on each assembly. We have such a system that is currently working, and it costs about two days to write, but it saved us a lot (we have more complex rules and a multi-implementation project, so it was worth the effort).
I will not write about this check in detail here right now (this is not so short), but I am going to write a blog post about this in the near future - most likely, by the end of this week. So, if you're interested, just check out my blog soon :)
UPD: Here it is.
Ivan Danilov Jul 21 '11 at 6:01 2011-07-21 06:01
source share