Generate an empty MSBuild project file

Sep 22, 2006 at 5:04 PM
Here's a script that I wrote this morning for something that I found I was doing a lot - generating empty MSBuild project files.

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using Microsoft.Tools.CodeRunner;
/// <summary>
/// Creates a bare bones MSBuild project file.
/// </summary>
public class Program
	public static int Main(string[] args)
		if (args.Length == 0)
			Console.WriteLine("Usage: {0} <proj-file>", ScriptEnvironment.ScriptPath.FileAndExtension);
			return 0;
		File.WriteAllText(args[0], @"<?xml version=""1.0"" encoding=""utf-8""?>
<Project DefaultTargets=""Build"" xmlns="""">
		<Compile Include=""MyProgram.cs"" />
	<Target Name=""Build""/>
	<Target Name=""Clean""/>
	<Target Name=""Rebuild"" DependsOnTargets=""Clean;Build""/>
		return 0;
Sep 22, 2006 at 5:07 PM
Just save the program in a file called GenProjFile.csr and type GenProjFile MyProject.proj to use it.