Пример #1
0
        static void Main()
        {
            if (!File.Exists(ProjectToDebug))
            {
                throw new FileNotFoundException(String.Format("The project file '{0}' does not exist. Set the ProjectToDebug field to the full path of the project you want to debug.", ProjectToDebug), ProjectToDebug);
            }
            if (!String.IsNullOrEmpty(SingleItem) && !File.Exists(Path.Combine(WorkingDirectory, SingleItem)))
            {
                throw new FileNotFoundException(String.Format("The project item '{0}' does not exist. Set the SingleItem field to the relative path of the content item you want to debug, or leave it empty to debug the whole project.", SingleItem), SingleItem);
            }
            Environment.CurrentDirectory = WorkingDirectory;

            var globalProperties = new Dictionary <string, string>();

            globalProperties.Add("Configuration", Configuration);
            globalProperties.Add("XnaProfile", XnaProfile.ToString());
            globalProperties.Add("XNAContentPipelineTargetPlatform", XnaContentPipelineTargetPlatform);
            globalProperties.Add("SingleItem", SingleItem);
            globalProperties.Add("CustomAfterMicrosoftCommonTargets", DebuggingTargets);

            var project = ProjectCollection.GlobalProjectCollection.LoadProject(ProjectName, globalProperties, MSBuildVersion);

            bool succeeded = project.Build("rebuild", Loggers);

            // To read the build output in the console window, place a breakpoint on the
            // Debug.WriteLine statement below.
            Debug.WriteLine("Build " + (succeeded ? "Succeeded." : "Failed."));
        }
Пример #2
0
 string ReplaceSymbols(string parameter)
 {
     if (string.IsNullOrWhiteSpace(parameter))
     {
         return(parameter);
     }
     return(parameter
            .Replace("$(Platform)", Platform.ToString())
            .Replace("$(Configuration)", Config)
            .Replace("$(Config)", Config)
            .Replace("$(Profile)", Profile.ToString()));
 }
Пример #3
0
 public ContentBuilder(string contentProjectFile, GraphicsProfile graphicsProfile = GraphicsProfile.HiDef, TargetPlatform targetPlatform = TargetPlatform.Windows, bool compressContent = true, LoggerVerbosity loggerVerbosity = LoggerVerbosity.Normal, bool rebuildContent = false)
 {
     FileInfo fileInfo = new FileInfo(contentProjectFile);
     _contentProjectFile = Path.GetFullPath(fileInfo.FullName);
     if (fileInfo.Extension != ".contentproj")
         throw new NotSupportedException(string.Format("The file '{0}' is not a XNA content project.", _contentProjectFile));
     if (!fileInfo.Exists)
         throw new FileNotFoundException(String.Format("The file '{0}' does not exist.", _contentProjectFile, _contentProjectFile));
     GraphicsProfile = graphicsProfile;
     TargetPlatform = targetPlatform;
     CompressContent = compressContent;
     LoggerVerbosity = loggerVerbosity;
     RebuildContent = rebuildContent;
     if (!_globalProperties.ContainsKey("XnaProfile"))
         _globalProperties.Add("XnaProfile", GraphicsProfile.ToString());
     if (!_globalProperties.ContainsKey("XNAContentPipelineTargetPlatform"))
         _globalProperties.Add("XNAContentPipelineTargetPlatform", TargetPlatform.ToString());
     if (!_globalProperties.ContainsKey("XnaCompressContent"))
         _globalProperties.Add("XnaCompressContent", CompressContent.ToString());
     if (!_globalProperties.ContainsKey("OutputhPath"))
         _globalProperties.Add("OutputPath", OutputPath);
     if (!_globalProperties.ContainsKey("ContentRootDirectory"))
         _globalProperties.Add("ContentRootDirectory", ContentRootDirectory);
 }