/// <summary> /// Creates a temporary MSBuild content project in memory. /// </summary> void CreateBuildProject() { string projectPath = Path.Combine(buildDirectory, "content.contentproj"); string outputPath = Path.Combine(buildDirectory, "bin"); // Create the build project. projectRootElement = ProjectRootElement.Create(); //projectRootElement = ProjectRootElement.Create(projectPath); // Include the standard targets file that defines how to build XNA Framework content. projectRootElement.AddImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA Game Studio\\" + "v4.0\\Microsoft.Xna.GameStudio.ContentPipeline.targets"); buildProject = new Project(projectRootElement); buildProject.SetProperty("XnaPlatform", "Windows"); buildProject.SetProperty("XnaProfile", "HiDef"); buildProject.SetProperty("XnaFrameworkVersion", "v4.0"); buildProject.SetProperty("Configuration", "Release"); buildProject.SetProperty("OutputPath", outputPath); // Register any custom importers or processors. foreach (string pipelineAssembly in pipelineAssemblies) { buildProject.AddItem("Reference", pipelineAssembly); } // Hook up our custom error logger. errorLogger = new ErrorLogger(); buildParameters = new BuildParameters(ProjectCollection.GlobalProjectCollection); buildParameters.Loggers = new ILogger[] { errorLogger }; }
/// <summary> /// Creates a temporary MSBuild content project in memory. /// </summary> void CreateBuildProject() { string projectPath = Path.Combine(buildDirectory, "content.contentproj"); string outputPath = Path.Combine(buildDirectory, "bin"); // Create the build engine. msBuildEngine = new Engine(); // Hook up our custom error logger. errorLogger = new ErrorLogger(); msBuildEngine.RegisterLogger(errorLogger); // Create the build project. msBuildProject = new Project(msBuildEngine); msBuildProject.FullFileName = projectPath; msBuildProject.SetProperty("XnaPlatform", "Windows"); msBuildProject.SetProperty("XnaFrameworkVersion", "v3.1"); msBuildProject.SetProperty("Configuration", "Release"); msBuildProject.SetProperty("OutputPath", outputPath); // Register any custom importers or processors. foreach (string pipelineAssembly in pipelineAssemblies) { msBuildProject.AddNewItem("Reference", pipelineAssembly); } // Include the standard targets file that defines // how to build XNA Framework content. msBuildProject.AddNewImport("$(MSBuildExtensionsPath)\\Microsoft\\XNA " + "Game Studio\\v3.1\\Microsoft.Xna.GameStudio" + ".ContentPipeline.targets", null); }