private static void LoadSettings(System.Xml.XmlDocument xmlDocument, Models.Project project) { foreach (System.Xml.XmlNode node in xmlDocument.GetElementsByTagName("Settings")) { string ApplicationIcon = node.Attributes["ApplicationIcon"].Value; string AssemblyKeyContainerName = node.Attributes["AssemblyKeyContainerName"].Value; string AssemblyName = node.Attributes["AssemblyName"].Value; string AssemblyOriginatorKeyFile = node.Attributes["AssemblyOriginatorKeyFile"].Value; string DefaultClientScript = node.Attributes["DefaultClientScript"].Value; string DefaultHTMLPageLayout = node.Attributes["DefaultHTMLPageLayout"].Value; string DefaultTargetSchema = node.Attributes["DefaultTargetSchema"].Value; string DelaySign = node.Attributes["DelaySign"].Value; string OutputType = node.Attributes["OutputType"].Value; string PreBuildEvent = node.Attributes["PreBuildEvent"].Value; string PostBuildEvent = node.Attributes["PostBuildEvent"].Value; string RootNamespace = node.Attributes["RootNamespace"].Value; string RunPostBuildEvent = node.Attributes["RunPostBuildEvent"].Value; string StartupObject = node.Attributes["StartupObject"].Value; Models.Settings settings = new Models.Settings(); settings.ApplicationIcon = ApplicationIcon; settings.AssemblyKeyContainerName = AssemblyKeyContainerName; settings.AssemblyName = AssemblyName; settings.AssemblyOriginatorKeyFile = AssemblyOriginatorKeyFile; settings.DefaultClientScript = DefaultClientScript; settings.DefaultHTMLPageLayout = DefaultHTMLPageLayout; settings.DefaultTargetSchema = DefaultTargetSchema; settings.DelaySign = DelaySign; settings.OutputType = OutputType; settings.PreBuildEvent = PreBuildEvent; settings.PostBuildEvent = PostBuildEvent; settings.RootNamespace = RootNamespace; settings.RunPostBuildEvent = RunPostBuildEvent; settings.StartupObject = StartupObject; project.Settings = settings; } }
public void Build(string filename, string configuration, string output, ProjectBuildTracker projectBuildTracker) { System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename); string name = fileInfo.Name.Substring(0, fileInfo.Name.ToLower().LastIndexOf(".csproj")); System.IO.TextReader reader = fileInfo.OpenText(); Models.Project project = ProjectReader.Read(name, reader); reader.Close(); if (!output.EndsWith(System.IO.Path.DirectorySeparatorChar.ToString())) { output += System.IO.Path.DirectorySeparatorChar; } string outputFolder = output; string extension = (project.Settings.OutputType.ToUpper().Equals("EXE") || project.Settings.OutputType.ToUpper().Equals("WINEXE")) ? ".exe" : ".dll"; output += project.Settings.AssemblyName + extension; string projectFolder = LastLeft(filename, System.IO.Path.DirectorySeparatorChar.ToString()); this.Build(project, configuration, projectFolder, output, outputFolder, projectBuildTracker); }
private static void LoadFiles(System.Xml.XmlDocument xmlDocument, Models.Project project) { foreach (System.Xml.XmlNode node in xmlDocument.GetElementsByTagName("File")) { Models.Item item = new Models.Item(); foreach (System.Xml.XmlAttribute attribute in node.Attributes) { switch (attribute.LocalName) { case "RelPath": { item.RelPath = node.Attributes["RelPath"].Value; break; } case "SubType": { item.SubType = node.Attributes["SubType"].Value; break; } case "DependentUpon": { item.DependentUpon = node.Attributes["DependentUpon"].Value; break; } case "BuildAction": { item.BuildAction = node.Attributes["BuildAction"].Value; break; } case "Generator": { item.Generator = node.Attributes["Generator"].Value; break; } case "LastGenOutput": { item.LastGenOutput = node.Attributes["LastGenOutput"].Value; break; } case "DesignTime": { item.DesignTime = node.Attributes["DesignTime"].Value; break; } case "AutoGen": { item.AutoGen = node.Attributes["AutoGen"].Value; break; } default: { throw new System.Exception("Unknown project file attribute: " + attribute.LocalName); } } } project.Items.Add(item); } }
private static void LoadReferences(System.Xml.XmlDocument xmlDocument, Models.Project project) { foreach (System.Xml.XmlNode node in xmlDocument.GetElementsByTagName("Reference")) { Models.Reference reference = new Models.Reference(); foreach (System.Xml.XmlAttribute attribute in node.Attributes) { switch (attribute.LocalName) { case "Name": { reference.Name = node.Attributes["Name"].Value; break; } case "AssemblyName": { reference.AssemblyName = node.Attributes["AssemblyName"].Value; break; } case "HintPath": { reference.HintPath = node.Attributes["HintPath"].Value; break; } case "Project": { reference.Project = node.Attributes["Project"].Value; break; } case "Package": { reference.Package = node.Attributes["Package"].Value; break; } case "Guid": { reference.Guid = node.Attributes["Guid"].Value; break; } case "VersionMajor": { reference.VersionMajor = node.Attributes["VersionMajor"].Value; break; } case "VersionMinor": { reference.VersionMinor = node.Attributes["VersionMinor"].Value; break; } case "Lcid": { reference.Lcid = node.Attributes["Lcid"].Value; break; } case "WrapperTool": { reference.WrapperTool = node.Attributes["WrapperTool"].Value; break; } case "Private": { reference.Private = node.Attributes["Private"].Value; break; } case "AssemblyFolderKey": { reference.AssemblyFolderKey = node.Attributes["AssemblyFolderKey"].Value; break; } default: { throw new System.Exception("Unknown project reference attribute: " + attribute.LocalName); } } } project.References.Add(reference); } }
/// <summary> /// Writes a project to a file. /// </summary> /// <param name="solution"></param> /// <param name="filename"></param> public static void Write(Models.Project project, System.IO.TextWriter writer) { writer.WriteLine("<VisualStudioProject>"); writer.WriteLine(" <CSHARP"); writer.WriteLine(" ProjectType = \"" + project.ProjectType + "\""); writer.WriteLine(" ProductVersion = \"" + project.ProductVersion + "\""); writer.WriteLine(" SchemaVersion = \"" + project.SchemaVersion + "\""); writer.WriteLine(" ProjectGuid = \"{" + project.ProjectGuid.ToString().ToUpper() + "}\""); writer.WriteLine(" >"); writer.WriteLine(" <Build>"); writer.WriteLine(" <Settings"); writer.WriteLine(" ApplicationIcon = \"" + project.Settings.ApplicationIcon + "\""); writer.WriteLine(" AssemblyKeyContainerName = \"" + project.Settings.AssemblyKeyContainerName + "\""); writer.WriteLine(" AssemblyName = \"" + project.Settings.AssemblyName + "\""); writer.WriteLine(" AssemblyOriginatorKeyFile = \"" + project.Settings.AssemblyOriginatorKeyFile + "\""); writer.WriteLine(" DefaultClientScript = \"" + project.Settings.DefaultClientScript + "\""); writer.WriteLine(" DefaultHTMLPageLayout = \"" + project.Settings.DefaultHTMLPageLayout + "\""); writer.WriteLine(" DefaultTargetSchema = \"" + project.Settings.DefaultTargetSchema + "\""); writer.WriteLine(" DelaySign = \"" + project.Settings.DelaySign + "\""); writer.WriteLine(" OutputType = \"" + project.Settings.OutputType + "\""); writer.WriteLine(" PreBuildEvent = \"" + project.Settings.PreBuildEvent + "\""); writer.WriteLine(" PostBuildEvent = \"" + project.Settings.PostBuildEvent + "\""); writer.WriteLine(" RootNamespace = \"" + project.Settings.RootNamespace + "\""); writer.WriteLine(" RunPostBuildEvent = \"" + project.Settings.RunPostBuildEvent + "\""); writer.WriteLine(" StartupObject = \"" + project.Settings.StartupObject + "\""); writer.WriteLine(" >"); foreach (Models.Config config in project.Configs) { writer.WriteLine(" <Config"); writer.WriteLine(" Name = \"" + config.Name + "\""); writer.WriteLine(" AllowUnsafeBlocks = \"" + config.AllowUnsafeBlocks + "\""); writer.WriteLine(" BaseAddress = \"" + config.BaseAddress + "\""); writer.WriteLine(" CheckForOverflowUnderflow = \"" + config.CheckForOverflowUnderflow + "\""); writer.WriteLine(" ConfigurationOverrideFile = \"" + config.ConfigurationOverrideFile + "\""); writer.WriteLine(" DefineConstants = \"" + config.DefineConstants + "\""); writer.WriteLine(" DocumentationFile = \"" + config.DocumentationFile + "\""); writer.WriteLine(" DebugSymbols = \"" + config.DebugSymbols + "\""); writer.WriteLine(" FileAlignment = \"" + config.FileAlignment + "\""); writer.WriteLine(" IncrementalBuild = \"" + config.IncrementalBuild + "\""); writer.WriteLine(" NoStdLib = \"" + config.NoStdLib + "\""); writer.WriteLine(" NoWarn = \"" + config.NoWarn + "\""); writer.WriteLine(" Optimize = \"" + config.Optimize + "\""); writer.WriteLine(" OutputPath = \"" + config.OutputPath + "\""); writer.WriteLine(" RegisterForComInterop = \"" + config.RegisterForComInterop + "\""); writer.WriteLine(" RemoveIntegerChecks = \"" + config.RemoveIntegerChecks + "\""); writer.WriteLine(" TreatWarningsAsErrors = \"" + config.TreatWarningsAsErrors + "\""); writer.WriteLine(" WarningLevel = \"" + config.WarningLevel + "\""); writer.WriteLine(" />"); } writer.WriteLine(" </Settings>"); writer.WriteLine(" <References>"); foreach (Models.Reference reference in project.References) { writer.WriteLine(" <Reference"); writer.WriteLine(" Name = \"" + reference.Name + "\""); if (reference.AssemblyName.Length > 0) { writer.WriteLine(" AssemblyName = \"" + reference.AssemblyName + "\""); } if (reference.HintPath.Length > 0) { writer.WriteLine(" HintPath = \"" + reference.HintPath + "\""); } if (reference.Project.Length > 0) { writer.WriteLine(" Project = \"" + reference.Project + "\""); } if (reference.Package.Length > 0) { writer.WriteLine(" Package = \"" + reference.Package + "\""); } if (reference.Guid.Length > 0) { writer.WriteLine(" Guid = \"" + reference.Guid + "\""); } if (reference.VersionMajor.Length > 0) { writer.WriteLine(" VersionMajor = \"" + reference.VersionMajor + "\""); } if (reference.VersionMinor.Length > 0) { writer.WriteLine(" VersionMinor = \"" + reference.VersionMinor + "\""); } if (reference.Lcid.Length > 0) { writer.WriteLine(" Lcid = \"" + reference.Lcid + "\""); } if (reference.WrapperTool.Length > 0) { writer.WriteLine(" WrapperTool = \"" + reference.WrapperTool + "\""); } if (reference.Private.Length > 0) { writer.WriteLine(" Private = \"" + reference.Private + "\""); } if (reference.AssemblyFolderKey.Length > 0) { writer.WriteLine(" AssemblyFolderKey = \"" + reference.AssemblyFolderKey + "\""); } writer.WriteLine(" />"); } writer.WriteLine(" </References>"); writer.WriteLine(" </Build>"); writer.WriteLine(" <Files>"); writer.WriteLine(" <Include>"); foreach (Models.Item file in project.Items) { writer.WriteLine(" <File"); if (file.RelPath.Length > 0) { writer.WriteLine(" RelPath = \"" + file.RelPath + "\""); } if (file.DependentUpon.Length > 0) { writer.WriteLine(" DependentUpon = \"" + file.DependentUpon + "\""); } if (file.SubType.Length > 0) { writer.WriteLine(" SubType = \"" + file.SubType + "\""); } if (file.BuildAction.Length > 0) { writer.WriteLine(" BuildAction = \"" + file.BuildAction + "\""); } if (file.Generator.Length > 0) { writer.WriteLine(" Generator = \"" + file.Generator + "\""); } if (file.LastGenOutput.Length > 0) { writer.WriteLine(" LastGenOutput = \"" + file.LastGenOutput + "\""); } if (file.DesignTime.Length > 0) { writer.WriteLine(" DesignTime = \"" + file.DesignTime + "\""); } if (file.AutoGen.Length > 0) { writer.WriteLine(" AutoGen = \"" + file.AutoGen + "\""); } writer.WriteLine(" />"); } foreach (Models.Folder folder in project.Folders) { writer.WriteLine(" <Folder RelPath = \"" + folder.RelPath + "\" />"); } writer.WriteLine(" </Include>"); writer.WriteLine(" </Files>"); writer.WriteLine(" </CSHARP>"); writer.WriteLine("</VisualStudioProject>"); writer.WriteLine(""); writer.Flush(); }