/// <summary> /// Initializes a new instance of the <see cref="VSGenericTarget"/> class. /// </summary> protected VSGenericTarget() { tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP", "$(MSBuildBinPath)\\Microsoft.CSHARP.Targets"); tools["Database"] = new ToolInfo("Database", "{4F174C21-8C12-11D0-8340-0000F80270F8}", "dbp", "UNKNOWN"); tools["Boo"] = new ToolInfo("Boo", "{45CEA7DC-C2ED-48A6-ACE0-E16144C02365}", "booproj", "Boo", "$(BooBinPath)\\Boo.Microsoft.Build.targets"); tools["VisualBasic"] = new ToolInfo("VisualBasic", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic", "$(MSBuildBinPath)\\Microsoft.VisualBasic.Targets"); tools["Folder"] = new ToolInfo("Folder", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", null, null); }
private void CleanProject(ProjectNode project) { kernel.Log.Write("...Cleaning project: {0}", project.Name); ToolInfo toolInfo = (ToolInfo)tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); string userFile = projectFile + ".user"; Helper.DeleteIfExists(projectFile); Helper.DeleteIfExists(userFile); }
/// <summary> /// Equals operator /// </summary> /// <param name="obj">ToolInfo to compare</param> /// <returns>true if toolInfos are equal</returns> public override bool Equals(object obj) { if (obj == null) { throw new ArgumentNullException("obj"); } if (obj.GetType() != typeof(ToolInfo)) { return(false); } ToolInfo c = (ToolInfo)obj; return((this.name == c.name) && (this.guid == c.guid) && (this.fileExtension == c.fileExtension) && (this.importProject == c.importProject)); }
private void WriteProject(TextWriter ss, SolutionNode solution, string language, Guid guid, string name, string projectFullPath) { if (!tools.ContainsKey(language)) { throw new UnknownLanguageException("Unknown .NET language: " + language); } ToolInfo toolInfo = tools[language]; string path = Helper.MakePathRelativeTo(solution.FullPath, projectFullPath); path = Helper.MakeFilePath(path, name, toolInfo.FileExtension); WriteProject(ss, language, guid, name, path); }
private void WriteSolution(SolutionNode solution) { kernel.Log.Write("Creating {0} solution and project files", this.VersionName); foreach (ProjectNode project in solution.Projects) { kernel.Log.Write("...Creating project: {0}", project.Name); WriteProject(solution, project); } kernel.Log.Write(""); string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); StreamWriter ss = new StreamWriter(solutionFile); kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); using (ss) { ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); ss.WriteLine("# Visual Studio 2005"); foreach (ProjectNode project in solution.Projects) { if (!tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)tools[project.Language]; string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, toolInfo.FileExtension), project.Guid.ToString().ToUpper()); //ss.WriteLine(" ProjectSection(ProjectDependencies) = postProject"); //ss.WriteLine(" EndProjectSection"); ss.WriteLine("EndProject"); } if (solution.Files != null) { ss.WriteLine("Project(\"{0}\") = \"Solution Items\", \"Solution Items\", \"{1}\"", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}"); ss.WriteLine("\tProjectSection(SolutionItems) = preProject"); foreach (string file in solution.Files) { ss.WriteLine("\t\t{0} = {0}", file); } ss.WriteLine("\tEndProjectSection"); ss.WriteLine("EndProject"); } ss.WriteLine("Global"); ss.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution"); foreach (ConfigurationNode conf in solution.Configurations) { ss.WriteLine(" {0}|Any CPU = {0}|Any CPU", conf.Name); } ss.WriteLine(" EndGlobalSection"); if (solution.Projects.Count > 1) { ss.WriteLine(" GlobalSection(ProjectDependencies) = postSolution"); } foreach (ProjectNode project in solution.Projects) { for (int i = 0; i < project.References.Count; i++) { ReferenceNode refr = (ReferenceNode)project.References[i]; if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; ss.WriteLine(" ({{{0}}}).{1} = ({{{2}}})", project.Guid.ToString().ToUpper() , i, refProject.Guid.ToString().ToUpper() ); } } } if (solution.Projects.Count > 1) { ss.WriteLine(" EndGlobalSection"); } ss.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution"); foreach (ProjectNode project in solution.Projects) { foreach (ConfigurationNode conf in solution.Configurations) { ss.WriteLine(" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU", project.Guid.ToString().ToUpper(), conf.Name); ss.WriteLine(" {{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU", project.Guid.ToString().ToUpper(), conf.Name); } } ss.WriteLine(" EndGlobalSection"); ss.WriteLine(" GlobalSection(SolutionProperties) = preSolution"); ss.WriteLine(" HideSolutionNode = FALSE"); ss.WriteLine(" EndGlobalSection"); ss.WriteLine("EndGlobal"); } kernel.CurrentWorkingDirectory.Pop(); }
private void WriteProject(SolutionNode solution, ProjectNode project) { if (!tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); StreamWriter ps = new StreamWriter(projectFile); kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); #region Project File using (ps) { ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine(" <{0}", toolInfo.XMLTag); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <ProjectType>Local</ProjectType>"); ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion); ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion); ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); //ps.WriteLine(" <Build>"); //ps.WriteLine(" <Settings"); ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); ps.WriteLine(" <AssemblyKeyContainerName>"); ps.WriteLine(" </AssemblyKeyContainerName>"); ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); ps.WriteLine(" <SignAssembly>true</SignAssembly>"); break; } } ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); ps.WriteLine(" <DelaySign>false</DelaySign>"); //if(m_Version == VSVersion.VS70) // ps.WriteLine(" NoStandardLibraries = \"false\""); ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type.ToString()); ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); //ps.WriteLine(" >"); ps.WriteLine(" <FileUpgradeFlags>"); ps.WriteLine(" </FileUpgradeFlags>"); ps.WriteLine(" </PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup "); ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name); ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); ps.WriteLine(" <ConfigurationOverrideFile>"); ps.WriteLine(" </ConfigurationOverrideFile>"); ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]); ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", conf.Options["XmlDocFile"]); ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); // ps.WriteLine(" <IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"]); // if(m_Version == VSVersion.VS71) // { // ps.WriteLine(" NoStdLib = \"{0}\"", conf.Options["NoStdLib"]); // ps.WriteLine(" NoWarn = \"{0}\"", conf.Options["SuppressWarnings"]); // } ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); ps.WriteLine(" <OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); ps.WriteLine(" </PropertyGroup>"); } //ps.WriteLine(" </Settings>"); // Assembly References ps.WriteLine(" <ItemGroup>"); foreach (ReferenceNode refr in project.References) { if (!solution.ProjectsTable.ContainsKey(refr.Name)) { ps.Write(" <Reference"); ps.Write(" Include=\""); ps.Write(refr.Name); if (!string.IsNullOrEmpty(refr.Version)) { ps.Write(", Version="); ps.Write(refr.Version); } ps.WriteLine("\" >"); // TODO: Allow reference to *.exe files ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakePathRelativeTo(project.FullPath, refr.Path + "\\" + refr.Name + ".dll")); ps.WriteLine(" </Reference>"); } } ps.WriteLine(" </ItemGroup>"); //Project References ps.WriteLine(" <ItemGroup>"); foreach (ReferenceNode refr in project.References) { if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; // TODO: Allow reference to visual basic projects ps.WriteLine(" <ProjectReference Include=\"{0}\">", Helper.MakePathRelativeTo(project.FullPath, Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj"))); //<ProjectReference Include="..\..\RealmForge\Utility\RealmForge.Utility.csproj"> ps.WriteLine(" <Name>{0}</Name>", refProject.Name); // <Name>RealmForge.Utility</Name> ps.WriteLine(" <Project>{{{0}}}</Project>", refProject.Guid.ToString().ToUpper()); // <Project>{6880D1D3-69EE-461B-B841-5319845B20D3}</Project> ps.WriteLine(" <Package>{0}</Package>", toolInfo.Guid.ToString().ToUpper()); // <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> ps.WriteLine(" </ProjectReference>"); //</ProjectReference> } else { } } ps.WriteLine(" </ItemGroup>"); // ps.WriteLine(" </Build>"); ps.WriteLine(" <ItemGroup>"); // ps.WriteLine(" <Include>"); ArrayList list = new ArrayList(); foreach (string file in project.Files) { // if (file == "Properties\\Bind.Designer.cs") // { // Console.WriteLine("Wait a minute!"); // Console.WriteLine(project.Files.GetSubType(file).ToString()); // } if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings && project.Files.GetSubType(file) != SubType.Designer) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); int slash = file.LastIndexOf('\\'); if (slash == -1) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file); } else { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(slash + 1, file.Length - slash - 1)); } ps.WriteLine(" <SubType>Designer</SubType>"); ps.WriteLine(" </EmbeddedResource>"); // } if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) == SubType.Designer) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); ps.WriteLine(" <SubType>" + project.Files.GetSubType(file) + "</SubType>"); ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); ps.WriteLine(" <LastGenOutput>Resources.Designer.cs</LastGenOutput>"); ps.WriteLine(" </EmbeddedResource>"); ps.WriteLine(" <Compile Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DesignTime>True</DesignTime>"); ps.WriteLine(" <DependentUpon>Resources.resx</DependentUpon>"); ps.WriteLine(" </Compile>"); list.Add(file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"); } if (project.Files.GetSubType(file).ToString() == "Settings") { //Console.WriteLine("File: " + file); //Console.WriteLine("Last index: " + file.LastIndexOf('.')); //Console.WriteLine("Length: " + file.Length); ps.Write(" <{0} ", project.Files.GetBuildAction(file)); ps.WriteLine("Include=\"{0}\">", file); int slash = file.LastIndexOf('\\'); string fileName = file.Substring(slash + 1, file.Length - slash - 1); if (project.Files.GetBuildAction(file) == BuildAction.None) { ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); //Console.WriteLine("FileName: " + fileName); //Console.WriteLine("FileNameMain: " + fileName.Substring(0, fileName.LastIndexOf('.'))); //Console.WriteLine("FileNameExt: " + fileName.Substring(fileName.LastIndexOf('.'), fileName.Length - fileName.LastIndexOf('.'))); if (slash == -1) { ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); } else { ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); } } else { ps.WriteLine(" <SubType>Code</SubType>"); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", fileNameShorter + ".settings"); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); } else if (project.Files.GetSubType(file) != SubType.Designer) { if (!list.Contains(file)) { ps.Write(" <{0} ", project.Files.GetBuildAction(file)); ps.WriteLine("Include=\"{0}\">", file); if (file.Contains("Designer.cs")) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", file.Substring(0, file.IndexOf(".Designer.cs")) + ".cs"); } if (project.Files.GetIsLink(file)) { ps.WriteLine(" <Link>{0}</Link>", Path.GetFileName(file)); } else if (project.Files.GetBuildAction(file) != BuildAction.None) { if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) { ps.WriteLine(" <SubType>{0}</SubType>", project.Files.GetSubType(file)); } } if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) { ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(file)); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); } } } // ps.WriteLine(" </Include>"); ps.WriteLine(" </ItemGroup>"); ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <PreBuildEvent>"); ps.WriteLine(" </PreBuildEvent>"); ps.WriteLine(" <PostBuildEvent>"); ps.WriteLine(" </PostBuildEvent>"); ps.WriteLine(" </PropertyGroup>"); // ps.WriteLine(" </{0}>", toolInfo.XMLTag); ps.WriteLine("</Project>"); } #endregion #region User File ps = new StreamWriter(projectFile + ".user"); using (ps) { ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine( "<VisualStudioProject>" ); //ps.WriteLine(" <{0}>", toolInfo.XMLTag); //ps.WriteLine(" <Build>"); ps.WriteLine(" <PropertyGroup>"); //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion); ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); ps.WriteLine(" </PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup"); ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name); ps.WriteLine(" />"); } //ps.WriteLine(" </Settings>"); //ps.WriteLine(" </Build>"); //ps.WriteLine(" </{0}>", toolInfo.XMLTag); //ps.WriteLine("</VisualStudioProject>"); ps.WriteLine("</Project>"); } #endregion kernel.CurrentWorkingDirectory.Pop(); }
private void WriteProject(SolutionNode solution, ProjectNode project) { if (!tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); StreamWriter ps = new StreamWriter(projectFile); kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); #region Project File using (ps) { string targets = ""; if (project.Files.CopyFiles > 0) { targets = "Build;CopyFiles"; } else { targets = "Build"; } ps.WriteLine("<Project DefaultTargets=\"{0}\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" {1}>", targets, GetToolsVersionXml(project.FrameworkVersion)); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <ProjectType>Local</ProjectType>"); ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", ProductVersion); ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", SchemaVersion); ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); // Visual Studio has a hard coded guid for the project type if (project.Type == ProjectType.Web) { ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>"); } ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); ps.WriteLine(" <AssemblyKeyContainerName>"); ps.WriteLine(" </AssemblyKeyContainerName>"); ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); ps.WriteLine(" <SignAssembly>true</SignAssembly>"); break; } } ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); ps.WriteLine(" <DelaySign>false</DelaySign>"); ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", ".")); ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); if (string.IsNullOrEmpty(project.DebugStartParameters)) { ps.WriteLine(" <StartArguments>{0}</StartArguments>", project.DebugStartParameters); } ps.WriteLine(" <FileUpgradeFlags>"); ps.WriteLine(" </FileUpgradeFlags>"); ps.WriteLine(" <ReleaseVersion>{0}</ReleaseVersion>", solution.Version); ps.WriteLine(" <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>"); ps.WriteLine(" </PropertyGroup>"); if (!string.IsNullOrEmpty(project.ApplicationManifest)) { ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <ApplicationManifest>"+ project.ApplicationManifest + "</ApplicationManifest>"); ps.WriteLine(" </PropertyGroup>"); } foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup "); ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \">", conf.Name, conf.Platform); ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); ps.WriteLine(" <ConfigurationOverrideFile>"); ps.WriteLine(" </ConfigurationOverrideFile>"); ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", (string)conf.Options["CompilerDefines"] == "" ? this.kernel.ForcedConditionals : conf.Options["CompilerDefines"] + ";" + kernel.ForcedConditionals); ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); if (project.Type != ProjectType.Web) { ps.WriteLine(" <OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); } else { ps.WriteLine(" <OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath("bin\\"))); } ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]); ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Platform); ps.WriteLine(" </PropertyGroup>"); } //ps.WriteLine(" </Settings>"); Dictionary <ReferenceNode, ProjectNode> projectReferences = new Dictionary <ReferenceNode, ProjectNode>(); List <ReferenceNode> otherReferences = new List <ReferenceNode>(); foreach (ReferenceNode refr in project.References) { ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); if (projectNode == null) { otherReferences.Add(refr); } else { projectReferences.Add(refr, projectNode); } } // Assembly References ps.WriteLine(" <ItemGroup>"); foreach (ReferenceNode refr in otherReferences) { ps.Write(" <Reference"); ps.Write(" Include=\""); ps.Write(refr.Name); ps.WriteLine("\">"); ps.Write(" <Name>"); ps.Write(refr.Name); ps.WriteLine("</Name>"); if (!String.IsNullOrEmpty(refr.Path)) { // Use absolute path to assembly (for determining assembly type) string absolutePath = Path.Combine(project.FullPath, refr.Path); if (File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "exe"))) { // Assembly is an executable (exe) ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "exe")); } else if (File.Exists(Helper.MakeFilePath(absolutePath, refr.Name, "dll"))) { // Assembly is an library (dll) ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); } else { string referencePath = Helper.MakeFilePath(refr.Path, refr.Name, "dll"); kernel.Log.Write(LogType.Warning, "Reference \"{0}\": The specified file doesn't exist.", referencePath); ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); } } ps.WriteLine(" <Private>{0}</Private>", refr.LocalCopy); ps.WriteLine(" </Reference>"); } ps.WriteLine(" </ItemGroup>"); //Project References ps.WriteLine(" <ItemGroup>"); foreach (KeyValuePair <ReferenceNode, ProjectNode> pair in projectReferences) { ToolInfo tool = tools[pair.Value.Language]; if (tools == null) { throw new UnknownLanguageException(); } string path = Helper.MakePathRelativeTo(project.FullPath, Helper.MakeFilePath(pair.Value.FullPath, pair.Value.Name, tool.FileExtension)); ps.WriteLine(" <ProjectReference Include=\"{0}\">", path); // TODO: Allow reference to visual basic projects ps.WriteLine(" <Name>{0}</Name>", pair.Value.Name); ps.WriteLine(" <Project>{0}</Project>", pair.Value.Guid.ToString("B").ToUpper()); ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper()); //This is the Copy Local flag in VS ps.WriteLine(" <Private>{0}</Private>", pair.Key.LocalCopy); ps.WriteLine(" </ProjectReference>"); } ps.WriteLine(" </ItemGroup>"); // ps.WriteLine(" </Build>"); ps.WriteLine(" <ItemGroup>"); // ps.WriteLine(" <Include>"); List <string> list = new List <string>(); foreach (string path in project.Files) { string lower = path.ToLower(); if (lower.EndsWith(".resx")) { string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); if (!list.Contains(codebehind)) { list.Add(codebehind); } } } foreach (string filePath in project.Files) { // Add the filePath with the destination as the key // will use it later to form the copy parameters with Include lists // for each destination if (project.Files.GetBuildAction(filePath) == BuildAction.Copy) { continue; } // if (file == "Properties\\Bind.Designer.cs") // { // Console.WriteLine("Wait a minute!"); // Console.WriteLine(project.Files.GetSubType(file).ToString()); // } SubType subType = project.Files.GetSubType(filePath); // Visual Studio chokes on file names if forward slash is used as a path separator // instead of backslash. So we must make sure that all file paths written to the // project file use \ as a path separator. string file = filePath.Replace(@"/", @"\"); if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer && subType != SubType.CodeBehind) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); ps.WriteLine(" <SubType>Designer</SubType>"); ps.WriteLine(" </EmbeddedResource>"); // } if (subType == SubType.Designer) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file); string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; string dependent_name = filePath.Substring(0, file.LastIndexOf('.')) + ".cs"; // Check for a parent .cs file with the same name as this designer file if (File.Exists(Helper.NormalizePath(dependent_name))) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); } else { ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name)); ps.WriteLine(" <SubType>"+ subType + "</SubType>"); } ps.WriteLine(" </EmbeddedResource>"); if (File.Exists(Helper.NormalizePath(autogen_name))) { ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name); //ps.WriteLine(" <DesignTime>True</DesignTime>"); // If a parent .cs file exists, link this autogen file to it. Otherwise link // to the designer file if (File.Exists(dependent_name)) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); } else { ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(filePath)); } ps.WriteLine(" </Compile>"); } list.Add(autogen_name); } if (subType == SubType.Settings) { ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); ps.WriteLine("Include=\"{0}\">", file); string fileName = Path.GetFileName(filePath); if (project.Files.GetBuildAction(filePath) == BuildAction.None) { ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); } else { ps.WriteLine(" <SubType>Code</SubType>"); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings")); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); } else if (subType != SubType.Designer) { string path = Helper.NormalizePath(file); string path_lower = path.ToLower(); if (!list.Contains(filePath)) { ps.Write(" <{0} ", project.Files.GetBuildAction(filePath)); int startPos = 0; if (project.Files.GetPreservePath(filePath)) { while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) { startPos++; } } else { startPos = file.LastIndexOf(Path.GetFileName(path)); } // be sure to write out the path with backslashes so VS recognizes // the file properly. ps.WriteLine("Include=\"{0}\">", file); int last_period_index = file.LastIndexOf('.'); string short_file_name = (last_period_index >= 0) ? file.Substring(0, last_period_index) : file; string extension = Path.GetExtension(path); // make this upper case, so that when File.Exists tests for the // existence of a designer file on a case-sensitive platform, // it is correctly identified. string designer_format = string.Format(".Designer{0}", extension); if (path_lower.EndsWith(designer_format.ToLowerInvariant())) { int designer_index = path.IndexOf(designer_format); string file_name = path.Substring(0, designer_index); // There are two corrections to the next lines: // 1. Fix the connection between a designer file and a form // or usercontrol that don't have an associated resx file. // 2. Connect settings files to associated designer files. if (File.Exists(file_name + extension)) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + extension)); } else if (File.Exists(file_name + ".resx")) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx")); } else if (File.Exists(file_name + ".settings")) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".settings")); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); } } else if (subType == SubType.CodeBehind) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name)); } if (project.Files.GetIsLink(filePath)) { string alias = project.Files.GetLinkPath(filePath); alias += file.Substring(startPos); alias = Helper.NormalizePath(alias); ps.WriteLine(" <Link>{0}</Link>", alias); } else if (project.Files.GetBuildAction(filePath) != BuildAction.None) { if (project.Files.GetBuildAction(filePath) != BuildAction.EmbeddedResource) { ps.WriteLine(" <SubType>{0}</SubType>", subType); } } if (project.Files.GetCopyToOutput(filePath) != CopyToOutput.Never) { ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(filePath)); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(filePath)); } } } ps.WriteLine(" </ItemGroup>"); /* * Copy Task * */ if (project.Files.CopyFiles > 0) { Dictionary <string, string> IncludeTags = new Dictionary <string, string>(); int TagCount = 0; // Handle Copy tasks ps.WriteLine(" <ItemGroup>"); foreach (string destPath in project.Files.Destinations) { string tag = "FilesToCopy_" + TagCount.ToString("0000"); ps.WriteLine(" <{0} Include=\"{1}\" />", tag, String.Join(";", project.Files.SourceFiles(destPath))); IncludeTags.Add(destPath, tag); TagCount++; } ps.WriteLine(" </ItemGroup>"); ps.WriteLine(" <Target Name=\"CopyFiles\">"); foreach (string destPath in project.Files.Destinations) { ps.WriteLine(" <Copy SourceFiles=\"@({0})\" DestinationFolder=\"{1}\" />", IncludeTags[destPath], destPath); } ps.WriteLine(" </Target>"); } ps.WriteLine(" <Import Project=\""+ toolInfo.ImportProject + "\" />"); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <PreBuildEvent>"); ps.WriteLine(" </PreBuildEvent>"); ps.WriteLine(" <PostBuildEvent>"); ps.WriteLine(" </PostBuildEvent>"); ps.WriteLine(" </PropertyGroup>"); ps.WriteLine("</Project>"); } #endregion #region User File ps = new StreamWriter(projectFile + ".user"); using (ps) { // Get the first configuration from the project. ConfigurationNode firstConfiguration = null; if (project.Configurations.Count > 0) { firstConfiguration = project.Configurations[0]; } ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine( "<VisualStudioProject>" ); //ps.WriteLine(" <{0}>", toolInfo.XMLTag); //ps.WriteLine(" <Build>"); ps.WriteLine(" <PropertyGroup>"); //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); if (firstConfiguration != null) { ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">{0}</Configuration>", firstConfiguration.Name); ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">{0}</Platform>", firstConfiguration.Platform); } ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", ProductVersion); ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); ps.WriteLine(" </PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup"); ps.Write(" Condition=\" '$(Configuration)|$(Platform)' == '{0}|{1}' \"", conf.Name, conf.Platform); ps.WriteLine(" />"); } ps.WriteLine("</Project>"); } #endregion kernel.CurrentWorkingDirectory.Pop(); }
/// <summary> /// Initializes a new instance of the <see cref="VS2003Target"/> class. /// </summary> public VS2003Target() { m_Tools = new Hashtable(); m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP"); m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic"); }
private void WriteProject(SolutionNode solution, ProjectNode project) { if (!tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); StreamWriter ps = new StreamWriter(projectFile); kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); #region Project File using (ps) { ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\" ToolsVersion=\"{0}\">", (this.Version == VSVersion.VS10 || this.Version == VSVersion.VS11) ? "4.0" : "3.5"); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <ProjectType>Local</ProjectType>"); ps.WriteLine(" <ProductVersion>{0}</ProductVersion>", this.ProductVersion); ps.WriteLine(" <SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion); ps.WriteLine(" <ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); // Visual Studio has a hard coded guid for the project type if (project.Type == ProjectType.Web) { ps.WriteLine(" <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>"); } ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); ps.WriteLine(" <ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); ps.WriteLine(" <AssemblyKeyContainerName>"); ps.WriteLine(" </AssemblyKeyContainerName>"); ps.WriteLine(" <AssemblyName>{0}</AssemblyName>", project.AssemblyName); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options.KeyFile != "") { ps.WriteLine(" <AssemblyOriginatorKeyFile>{0}</AssemblyOriginatorKeyFile>", conf.Options.KeyFile); ps.WriteLine(" <SignAssembly>true</SignAssembly>"); break; } } ps.WriteLine(" <DefaultClientScript>JScript</DefaultClientScript>"); ps.WriteLine(" <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); ps.WriteLine(" <DefaultTargetSchema>IE50</DefaultTargetSchema>"); ps.WriteLine(" <DelaySign>false</DelaySign>"); ps.WriteLine(" <TargetFrameworkVersion>{0}</TargetFrameworkVersion>", project.FrameworkVersion.ToString().Replace("_", ".")); ps.WriteLine(" <OutputType>{0}</OutputType>", project.Type == ProjectType.Web ? ProjectType.Library.ToString() : project.Type.ToString()); ps.WriteLine(" <AppDesignerFolder>{0}</AppDesignerFolder>", project.DesignerFolder); ps.WriteLine(" <RootNamespace>{0}</RootNamespace>", project.RootNamespace); ps.WriteLine(" <StartupObject>{0}</StartupObject>", project.StartupObject); ps.WriteLine(" <FileUpgradeFlags>"); ps.WriteLine(" </FileUpgradeFlags>"); ps.WriteLine(" </PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { string compilerDefines = conf.Options["CompilerDefines"].ToString(); if (compilerDefines != String.Empty) { compilerDefines += ";"; } compilerDefines += "VISUAL_STUDIO"; ps.Write(" <PropertyGroup "); ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name); ps.WriteLine(" <AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); ps.WriteLine(" <BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); ps.WriteLine(" <CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); ps.WriteLine(" <ConfigurationOverrideFile>"); ps.WriteLine(" </ConfigurationOverrideFile>"); ps.WriteLine(" <DefineConstants>{0}</DefineConstants>", compilerDefines); ps.WriteLine(" <DocumentationFile>{0}</DocumentationFile>", Helper.NormalizePath(conf.Options["XmlDocFile"].ToString())); ps.WriteLine(" <DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); ps.WriteLine(" <FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); ps.WriteLine(" <Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); if (project.Type != ProjectType.Web) { ps.WriteLine(" <OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); } else { ps.WriteLine(" <OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath("bin\\"))); } ps.WriteLine(" <RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); ps.WriteLine(" <RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); ps.WriteLine(" <TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); ps.WriteLine(" <WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); ps.WriteLine(" <NoStdLib>{0}</NoStdLib>", conf.Options["NoStdLib"]); ps.WriteLine(" <NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); ps.WriteLine(" <PlatformTarget>{0}</PlatformTarget>", conf.Options.PlatformTarget); ps.WriteLine(" </PropertyGroup>"); } //ps.WriteLine(" </Settings>"); ArrayList projectReferences = new ArrayList(), otherReferences = new ArrayList(); foreach (ReferenceNode refr in project.References) { ProjectNode projectNode = FindProjectInSolution(refr.Name, solution); if (projectNode == null) { if (!otherReferences.Contains(refr)) { otherReferences.Add(refr); } } else { refr.Name = refr.Name.Replace(".exe", String.Empty); projectReferences.Add(projectNode); } } // Assembly References ps.WriteLine(" <ItemGroup>"); foreach (ReferenceNode refr in otherReferences) { ps.Write(" <Reference"); ps.Write(" Include=\""); ps.Write(refr.Name); ps.WriteLine("\">"); ps.Write(" <Name>"); ps.Write(refr.Name); ps.WriteLine("</Name>"); // TODO: Allow reference to *.exe files if (!String.IsNullOrEmpty(refr.Path)) { ps.WriteLine(" <HintPath>{0}</HintPath>", Helper.MakePathRelativeTo(project.FullPath, refr.Path + "\\" + refr.Name + ".dll")); } else { foreach (ReferencePathNode node in project.ReferencePaths) { try { string fullRefPath = Helper.ResolvePath(node.Path); if (File.Exists(fullRefPath + refr.Name + ".dll")) { ps.WriteLine(" <HintPath>{0}</HintPath>", fullRefPath + refr.Name + ".dll"); break; } else if (File.Exists(fullRefPath + refr.Name + ".exe")) { ps.WriteLine(" <HintPath>{0}</HintPath>", fullRefPath + refr.Name + ".exe"); break; } } catch (Exception) { } } } ps.WriteLine(" </Reference>"); } ps.WriteLine(" </ItemGroup>"); //Project References ps.WriteLine(" <ItemGroup>"); foreach (ProjectNode projectReference in projectReferences) { ToolInfo tool = (ToolInfo)tools[projectReference.Language]; if (tools == null) { throw new UnknownLanguageException(); } // TODO: Allow reference to visual basic projects ps.WriteLine(" <ProjectReference Include=\"{0}\">", Helper.MakePathRelativeTo(project.FullPath, Helper.MakeFilePath(projectReference.FullPath, projectReference.Name, tool.FileExtension))); ps.WriteLine(" <Name>{0}</Name>", projectReference.Name); ps.WriteLine(" <Project>{0}</Project>", projectReference.Guid.ToString("B").ToUpper()); ps.WriteLine(" <Package>{0}</Package>", tool.Guid.ToUpper()); ps.WriteLine(" </ProjectReference>"); } ps.WriteLine(" </ItemGroup>"); // ps.WriteLine(" </Build>"); ps.WriteLine(" <ItemGroup>"); // ps.WriteLine(" <Include>"); ArrayList list = new ArrayList(); ArrayList filesToRemove = new ArrayList(); foreach (string path in project.Files) { string lower = path.ToLower(); if (lower.EndsWith(".resx")) { string codebehind = String.Format("{0}.Designer{1}", path.Substring(0, path.LastIndexOf('.')), toolInfo.LanguageExtension); if (!list.Contains(codebehind)) { list.Add(codebehind); } } } foreach (string file in project.Files) { // if (file == "Properties\\Bind.Designer.cs") // { // Console.WriteLine("Wait a minute!"); // Console.WriteLine(project.Files.GetSubType(file).ToString()); // } SubType subType = project.Files.GetSubType(file); if (file.EndsWith("Settings.Designer.cs")) { subType = SubType.Settings; } if (subType != SubType.Code && subType != SubType.Settings && subType != SubType.Designer && subType != SubType.CodeBehind) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx"); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); //ps.WriteLine(" <SubType>Designer</SubType>"); ps.WriteLine(" </EmbeddedResource>"); } if (subType == SubType.Designer) { ps.WriteLine(" <EmbeddedResource Include=\"{0}\">", file); string autogen_name = file.Substring(0, file.LastIndexOf('.')) + ".Designer.cs"; string dependent_name = file.Substring(0, file.LastIndexOf('.')) + ".cs"; // Check for a parent .cs file with the same name as this designer file if (File.Exists(dependent_name)) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); } else { /* * These two lines screw up the designer, ie: if you make a change to a form, * when you press Save VS corrups the .Designer.cs file */ ps.WriteLine(" <Generator>ResXFileCodeGenerator</Generator>"); ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name)); ps.WriteLine(" <SubType>" + subType + "</SubType>"); } ps.WriteLine(" </EmbeddedResource>"); /*if (File.Exists(autogen_name)) * { * ps.WriteLine(" <Compile Include=\"{0}\">", autogen_name); * //ps.WriteLine(" <DesignTime>True</DesignTime>"); * * // If a parent .cs file exists, link this autogen file to it. Otherwise link * // to the designer file * if (File.Exists(dependent_name)) * { * ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(dependent_name)); * } * else * { * ps.WriteLine(" <AutoGen>True</AutoGen>"); * ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file)); * } * * ps.WriteLine(" </Compile>"); * }*/ if (!list.Contains(autogen_name)) { list.Add(autogen_name); } } if (subType == SubType.Settings) { ps.Write(" <{0} ", project.Files.GetBuildAction(file)); ps.WriteLine("Include=\"{0}\">", file); string fileName = Path.GetFileName(file); if (project.Files.GetBuildAction(file) == BuildAction.None) { ps.WriteLine(" <Generator>SettingsSingleFileGenerator</Generator>"); ps.WriteLine(" <LastGenOutput>{0}</LastGenOutput>", fileName.Substring(0, fileName.LastIndexOf('.')) + ".Designer.cs"); } else { string fileNameShort = fileName.Substring(0, fileName.LastIndexOf('.')); string fileNameShorter = fileNameShort.Substring(0, fileNameShort.LastIndexOf('.')); ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(fileNameShorter + ".settings")); ps.WriteLine(" <DesignTimeSharedInput>True</DesignTimeSharedInput>"); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); } else if (subType != SubType.Designer) { string path = Helper.NormalizePath(file); string path_lower = path.ToLower(); //if (!list.Contains(file)) { ps.Write(" <{0} ", project.Files.GetBuildAction(path)); int startPos = 0; if (project.Files.GetPreservePath(file)) { while ((@"./\").IndexOf(file.Substring(startPos, 1)) != -1) { startPos++; } } else { startPos = file.LastIndexOf(Path.GetFileName(path)); } ps.WriteLine("Include=\"{0}\">", path); int last_period_index = file.LastIndexOf('.'); string short_file_name = file.Substring(0, last_period_index); string extension = Path.GetExtension(path); string designer_format = string.Format(".designer{0}", extension); if (path_lower.EndsWith(designer_format)) { int designer_index = path_lower.IndexOf(designer_format); string file_name = path.Substring(0, designer_index); if (File.Exists(file_name + ".cs")) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".cs")); } else if (File.Exists(file_name + ".resx")) { ps.WriteLine(" <AutoGen>True</AutoGen>"); ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name + ".resx")); } } else if (subType == SubType.CodeBehind) { ps.WriteLine(" <DependentUpon>{0}</DependentUpon>", Path.GetFileName(short_file_name)); } if (project.Files.GetIsLink(file)) { string alias = project.Files.GetLinkPath(file); alias += file.Substring(startPos); alias = Helper.NormalizePath(alias); ps.WriteLine(" <Link>{0}</Link>", alias); } else if (project.Files.GetBuildAction(file) != BuildAction.None) { if (project.Files.GetBuildAction(file) != BuildAction.EmbeddedResource) { //HACK: Ugly method of supporting WinForms if (file.Contains("frm") && !file.Contains("Designer.cs")) { ps.WriteLine(" <SubType>Form</SubType>"); } //else // ps.WriteLine(" <SubType>{0}</SubType>", subType); } } if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never) { ps.WriteLine(" <CopyToOutputDirectory>{0}</CopyToOutputDirectory>", project.Files.GetCopyToOutput(file)); } ps.WriteLine(" </{0}>", project.Files.GetBuildAction(file)); } } } ps.WriteLine(" </ItemGroup>"); ps.WriteLine(" <Import Project=\"" + toolInfo.ImportProject + "\" />"); ps.WriteLine(" <PropertyGroup>"); ps.WriteLine(" <PreBuildEvent>"); ps.WriteLine(" </PreBuildEvent>"); ps.WriteLine(" <PostBuildEvent>"); ps.WriteLine(" </PostBuildEvent>"); ps.WriteLine(" </PropertyGroup>"); ps.WriteLine("</Project>"); } #endregion #region User File ps = new StreamWriter(projectFile + ".user"); using (ps) { ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine( "<VisualStudioProject>" ); //ps.WriteLine(" <{0}>", toolInfo.XMLTag); //ps.WriteLine(" <Build>"); ps.WriteLine(" <PropertyGroup>"); //ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); ps.WriteLine(" <Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine(" <Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); ps.WriteLine(" <ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); ps.WriteLine(" <LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion); ps.WriteLine(" <ProjectView>ProjectFiles</ProjectView>"); ps.WriteLine(" <ProjectTrust>0</ProjectTrust>"); ps.WriteLine(" </PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write(" <PropertyGroup"); ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name); ps.WriteLine(" />"); } //ps.WriteLine(" </Settings>"); //ps.WriteLine(" </Build>"); //ps.WriteLine(" </{0}>", toolInfo.XMLTag); //ps.WriteLine("</VisualStudioProject>"); ps.WriteLine("</Project>"); } #endregion kernel.CurrentWorkingDirectory.Pop(); }
private void WriteSolution(SolutionNode solution) { m_Kernel.Log.Write("Creating Visual Studio {0} solution and project files", this.VersionName); foreach (ProjectNode project in solution.Projects) { if (m_Kernel.AllowProject(project.FilterGroups)) { m_Kernel.Log.Write("...Creating project: {0}", project.Name); WriteProject(solution, project); } } m_Kernel.Log.Write(""); string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln"); StreamWriter ss = new StreamWriter(solutionFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile)); using (ss) { ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion); foreach (ProjectNode project in solution.Projects) { if (!m_Tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath); ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"", toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name, toolInfo.FileExtension), project.Guid.ToString().ToUpper()); ss.WriteLine("\tProjectSection(ProjectDependencies) = postProject"); ss.WriteLine("\tEndProjectSection"); ss.WriteLine("EndProject"); } ss.WriteLine("Global"); ss.WriteLine("\tGlobalSection(SolutionConfiguration) = preSolution"); foreach (ConfigurationNode conf in solution.Configurations) { ss.WriteLine("\t\t{0} = {0}", conf.Name); } ss.WriteLine("\tEndGlobalSection"); ss.WriteLine("\tGlobalSection(ProjectDependencies) = postSolution"); foreach (ProjectNode project in solution.Projects) { for (int i = 0; i < project.References.Count; i++) { ReferenceNode refr = (ReferenceNode)project.References[i]; if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; ss.WriteLine("\t\t({{{0}}}).{1} = ({{{2}}})", project.Guid.ToString().ToUpper() , i, refProject.Guid.ToString().ToUpper() ); } } } ss.WriteLine("\tEndGlobalSection"); ss.WriteLine("\tGlobalSection(ProjectConfiguration) = postSolution"); foreach (ProjectNode project in solution.Projects) { foreach (ConfigurationNode conf in solution.Configurations) { ss.WriteLine("\t\t{{{0}}}.{1}.ActiveCfg = {1}|.NET", project.Guid.ToString().ToUpper(), conf.Name); ss.WriteLine("\t\t{{{0}}}.{1}.Build.0 = {1}|.NET", project.Guid.ToString().ToUpper(), conf.Name); } } ss.WriteLine("\tEndGlobalSection"); if (solution.Files != null) { ss.WriteLine("\tGlobalSection(SolutionItems) = postSolution"); foreach (string file in solution.Files) { ss.WriteLine("\t\t{0} = {0}", file); } ss.WriteLine("\tEndGlobalSection"); } ss.WriteLine("\tGlobalSection(ExtensibilityGlobals) = postSolution"); ss.WriteLine("\tEndGlobalSection"); ss.WriteLine("\tGlobalSection(ExtensibilityAddIns) = postSolution"); ss.WriteLine("\tEndGlobalSection"); ss.WriteLine("EndGlobal"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
private void WriteProject(SolutionNode solution, ProjectNode project) { if (!m_Tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)m_Tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); StreamWriter ps = new StreamWriter(projectFile); m_Kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); IEnumerator enumerator; //ConfigurationNode scripts; using (ps) { ps.WriteLine("<VisualStudioProject>"); ps.WriteLine(" <{0}", toolInfo.XmlTag); ps.WriteLine("\t\t\t\tProjectType = \"Local\""); ps.WriteLine("\t\t\t\tProductVersion = \"{0}\"", this.ProductVersion); ps.WriteLine("\t\t\t\tSchemaVersion = \"{0}\"", this.SchemaVersion); ps.WriteLine("\t\t\t\tProjectGuid = \"{{{0}}}\"", project.Guid.ToString().ToUpper()); ps.WriteLine("\t\t>"); ps.WriteLine("\t\t\t\t<Build>"); ps.WriteLine(" <Settings"); ps.WriteLine("\t\t\t\t ApplicationIcon = \"{0}\"", project.AppIcon); ps.WriteLine("\t\t\t\t AssemblyKeyContainerName = \"\""); ps.WriteLine("\t\t\t\t AssemblyName = \"{0}\"", project.AssemblyName); ps.WriteLine("\t\t\t\t AssemblyOriginatorKeyFile = \"\""); ps.WriteLine("\t\t\t\t DefaultClientScript = \"JScript\""); ps.WriteLine("\t\t\t\t DefaultHTMLPageLayout = \"Grid\""); ps.WriteLine("\t\t\t\t DefaultTargetSchema = \"IE50\""); ps.WriteLine("\t\t\t\t DelaySign = \"false\""); if (this.Version == VSVersion.VS70) { ps.WriteLine("\t\t\t\t NoStandardLibraries = \"false\""); } ps.WriteLine("\t\t\t\t OutputType = \"{0}\"", project.Type.ToString()); enumerator = project.Configurations.GetEnumerator(); enumerator.Reset(); enumerator.MoveNext(); foreach (ConfigurationNode conf in project.Configurations) { if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0) { ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString())); } else { ps.WriteLine("\t\t\t\t PreBuildEvent = \"{0}\"", conf.Options["PreBuildEvent"]); } if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0) { ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString())); } else { ps.WriteLine("\t\t\t\t PostBuildEvent = \"{0}\"", conf.Options["PostBuildEvent"]); } if (conf.Options["RunPostBuildEvent"] == null) { ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", "OnBuildSuccess"); } else { ps.WriteLine("\t\t\t\t RunPostBuildEvent = \"{0}\"", conf.Options["RunPostBuildEvent"]); } break; } ps.WriteLine("\t\t\t\t RootNamespace = \"{0}\"", project.RootNamespace); ps.WriteLine("\t\t\t\t StartupObject = \"{0}\"", project.StartupObject); ps.WriteLine("\t\t >"); foreach (ConfigurationNode conf in project.Configurations) { ps.WriteLine("\t\t\t\t <Config"); ps.WriteLine("\t\t\t\t Name = \"{0}\"", conf.Name); ps.WriteLine("\t\t\t\t AllowUnsafeBlocks = \"{0}\"", conf.Options["AllowUnsafe"].ToString().ToLower()); ps.WriteLine("\t\t\t\t BaseAddress = \"{0}\"", conf.Options["BaseAddress"]); ps.WriteLine("\t\t\t\t CheckForOverflowUnderflow = \"{0}\"", conf.Options["CheckUnderflowOverflow"].ToString().ToLower()); ps.WriteLine("\t\t\t\t ConfigurationOverrideFile = \"\""); ps.WriteLine("\t\t\t\t DefineConstants = \"{0}\"", conf.Options["CompilerDefines"]); ps.WriteLine("\t\t\t\t DocumentationFile = \"{0}\"", GetXmlDocFile(project, conf)); //default to the assembly name ps.WriteLine("\t\t\t\t DebugSymbols = \"{0}\"", conf.Options["DebugInformation"].ToString().ToLower()); ps.WriteLine("\t\t\t\t FileAlignment = \"{0}\"", conf.Options["FileAlignment"]); ps.WriteLine("\t\t\t\t IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"].ToString().ToLower()); if (this.Version == VSVersion.VS71) { ps.WriteLine("\t\t\t\t NoStdLib = \"{0}\"", conf.Options["NoStdLib"].ToString().ToLower()); ps.WriteLine("\t\t\t\t NoWarn = \"{0}\"", conf.Options["SuppressWarnings"].ToString().ToLower()); } ps.WriteLine("\t\t\t\t Optimize = \"{0}\"", conf.Options["OptimizeCode"].ToString().ToLower()); ps.WriteLine(" OutputPath = \"{0}\"", Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); ps.WriteLine(" RegisterForComInterop = \"{0}\"", conf.Options["RegisterComInterop"].ToString().ToLower()); ps.WriteLine(" RemoveIntegerChecks = \"{0}\"", conf.Options["RemoveIntegerChecks"].ToString().ToLower()); ps.WriteLine(" TreatWarningsAsErrors = \"{0}\"", conf.Options["WarningsAsErrors"].ToString().ToLower()); ps.WriteLine(" WarningLevel = \"{0}\"", conf.Options["WarningLevel"]); ps.WriteLine(" />"); } ps.WriteLine(" </Settings>"); ps.WriteLine(" <References>"); foreach (ReferenceNode refr in project.References) { ps.WriteLine(" <Reference"); ps.WriteLine(" Name = \"{0}\"", refr.Name); ps.WriteLine(" AssemblyName = \"{0}\"", refr.Name); if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; ps.WriteLine(" Project = \"{{{0}}}\"", refProject.Guid.ToString().ToUpper()); ps.WriteLine(" Package = \"{0}\"", toolInfo.Guid.ToString().ToUpper()); } else { if (refr.Path != null) { ps.WriteLine(" HintPath = \"{0}\"", Helper.MakeFilePath(refr.Path, refr.Name, "dll")); } } if (refr.LocalCopySpecified) { ps.WriteLine(" Private = \"{0}\"", refr.LocalCopy); } ps.WriteLine(" />"); } ps.WriteLine(" </References>"); ps.WriteLine(" </Build>"); ps.WriteLine(" <Files>"); ps.WriteLine(" <Include>"); foreach (string file in project.Files) { string fileName = file.Replace(".\\", ""); ps.WriteLine(" <File"); ps.WriteLine(" RelPath = \"{0}\"", fileName); ps.WriteLine(" SubType = \"{0}\"", project.Files.GetSubType(file)); ps.WriteLine(" BuildAction = \"{0}\"", project.Files.GetBuildAction(file)); ps.WriteLine(" />"); if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings) { ps.WriteLine(" <File"); ps.WriteLine(" RelPath = \"{0}\"", fileName.Substring(0, fileName.LastIndexOf('.')) + ".resx"); int slash = fileName.LastIndexOf('\\'); if (slash == -1) { ps.WriteLine(" DependentUpon = \"{0}\"", fileName); } else { ps.WriteLine(" DependentUpon = \"{0}\"", fileName.Substring(slash + 1, fileName.Length - slash - 1)); } ps.WriteLine(" BuildAction = \"{0}\"", "EmbeddedResource"); ps.WriteLine(" />"); } } ps.WriteLine(" </Include>"); ps.WriteLine(" </Files>"); ps.WriteLine(" </{0}>", toolInfo.XmlTag); ps.WriteLine("</VisualStudioProject>"); } ps = new StreamWriter(projectFile + ".user"); using (ps) { ps.WriteLine("<VisualStudioProject>"); ps.WriteLine(" <{0}>", toolInfo.XmlTag); ps.WriteLine(" <Build>"); ps.WriteLine(" <Settings ReferencePath=\"{0}\">", MakeRefPath(project)); foreach (ConfigurationNode conf in project.Configurations) { ps.WriteLine(" <Config"); ps.WriteLine(" Name = \"{0}\"", conf.Name); ps.WriteLine(" />"); } ps.WriteLine(" </Settings>"); ps.WriteLine(" </Build>"); ps.WriteLine(" </{0}>", toolInfo.XmlTag); ps.WriteLine("</VisualStudioProject>"); } m_Kernel.CurrentWorkingDirectory.Pop(); }
/// <summary> /// Initializes a new instance of the <see cref="VS2003Target"/> class. /// </summary> public VS2003Target() { m_Tools["C#"] = new ToolInfo("C#", "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}", "csproj", "CSHARP"); m_Tools["VB.NET"] = new ToolInfo("VB.NET", "{F184B08F-C81C-45F6-A57F-5ABD9991F28F}", "vbproj", "VisualBasic"); }
private void WriteProject(SolutionNode solution, ProjectNode project) { if (!tools.ContainsKey(project.Language)) { throw new UnknownLanguageException("Unknown .NET language: " + project.Language); } ToolInfo toolInfo = (ToolInfo)tools[project.Language]; string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, toolInfo.FileExtension); StreamWriter ps = new StreamWriter(projectFile); kernel.CurrentWorkingDirectory.Push(); Helper.SetCurrentDir(Path.GetDirectoryName(projectFile)); #region Project File using ( ps ) { ps.WriteLine("<Project DefaultTargets=\"Build\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine("\t<{0}", toolInfo.XMLTag); ps.WriteLine("\t<PropertyGroup>"); ps.WriteLine("\t\t<ProjectType>Local</ProjectType>"); ps.WriteLine("\t\t<ProductVersion>{0}</ProductVersion>", this.ProductVersion); ps.WriteLine("\t\t<SchemaVersion>{0}</SchemaVersion>", this.SchemaVersion); ps.WriteLine("\t\t<ProjectGuid>{{{0}}}</ProjectGuid>", project.Guid.ToString().ToUpper()); ps.WriteLine("\t\t<Configuration Condition = \" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine("\t\t<Platform Condition = \" '$(Platform)' == '' \">AnyCPU</Platform>"); //ps.WriteLine("\t\t<Build>"); //ps.WriteLine("\t\t\t<Settings"); ps.WriteLine("\t\t<ApplicationIcon>{0}</ApplicationIcon>", project.AppIcon); ps.WriteLine("\t\t<AssemblyKeyContainerName></AssemblyKeyContainerName>"); ps.WriteLine("\t\t<AssemblyName>{0}</AssemblyName>", project.AssemblyName); ps.WriteLine("\t\t<AssemblyOriginatorKeyFile></AssemblyOriginatorKeyFile>"); ps.WriteLine("\t\t<DefaultClientScript>JScript</DefaultClientScript>"); ps.WriteLine("\t\t<DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout>"); ps.WriteLine("\t\t<DefaultTargetSchema>IE50</DefaultTargetSchema>"); ps.WriteLine("\t\t<DelaySign>false</DelaySign>"); //if(m_Version == VSVersion.VS70) // ps.WriteLine("\t\t\t\tNoStandardLibraries = \"false\""); ps.WriteLine("\t\t<OutputType>{0}</OutputType>", project.Type.ToString()); ps.WriteLine("\t\t<RootNamespace>{0}</RootNamespace>", project.RootNamespace); ps.WriteLine("\t\t<StartupObject>{0}</StartupObject>", project.StartupObject); //ps.WriteLine("\t\t\t>"); ps.WriteLine("\t\t<FileUpgradeFlags></FileUpgradeFlags>"); ps.WriteLine("\t</PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write("\t<PropertyGroup "); ps.WriteLine("Condition=\" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \">", conf.Name); ps.WriteLine("\t\t<AllowUnsafeBlocks>{0}</AllowUnsafeBlocks>", conf.Options["AllowUnsafe"]); ps.WriteLine("\t\t<BaseAddress>{0}</BaseAddress>", conf.Options["BaseAddress"]); ps.WriteLine("\t\t<CheckForOverflowUnderflow>{0}</CheckForOverflowUnderflow>", conf.Options["CheckUnderflowOverflow"]); ps.WriteLine("\t\t<ConfigurationOverrideFile></ConfigurationOverrideFile>"); ps.WriteLine("\t\t<DefineConstants>{0}</DefineConstants>", conf.Options["CompilerDefines"]); ps.WriteLine("\t\t<DocumentationFile>{0}</DocumentationFile>", conf.Options["XmlDocFile"]); ps.WriteLine("\t\t<DebugSymbols>{0}</DebugSymbols>", conf.Options["DebugInformation"]); ps.WriteLine("\t\t<FileAlignment>{0}</FileAlignment>", conf.Options["FileAlignment"]); // ps.WriteLine("\t\t<IncrementalBuild = \"{0}\"", conf.Options["IncrementalBuild"]); // if(m_Version == VSVersion.VS71) // { // ps.WriteLine("\t\t\t\t\tNoStdLib = \"{0}\"", conf.Options["NoStdLib"]); // ps.WriteLine("\t\t\t\t\tNoWarn = \"{0}\"", conf.Options["SuppressWarnings"]); // } ps.WriteLine("\t\t<Optimize>{0}</Optimize>", conf.Options["OptimizeCode"]); ps.WriteLine("\t\t<OutputPath>{0}</OutputPath>", Helper.EndPath(Helper.NormalizePath(conf.Options["OutputPath"].ToString()))); ps.WriteLine("\t\t<RegisterForComInterop>{0}</RegisterForComInterop>", conf.Options["RegisterComInterop"]); ps.WriteLine("\t\t<RemoveIntegerChecks>{0}</RemoveIntegerChecks>", conf.Options["RemoveIntegerChecks"]); ps.WriteLine("\t\t<TreatWarningsAsErrors>{0}</TreatWarningsAsErrors>", conf.Options["WarningsAsErrors"]); ps.WriteLine("\t\t<WarningLevel>{0}</WarningLevel>", conf.Options["WarningLevel"]); ps.WriteLine("\t\t<NoWarn>{0}</NoWarn>", conf.Options["SuppressWarnings"]); ps.WriteLine("\t</PropertyGroup>"); } //ps.WriteLine("\t\t\t</Settings>"); // Assembly References ps.WriteLine("\t<ItemGroup>"); foreach (ReferenceNode refr in project.References) { if (!solution.ProjectsTable.ContainsKey(refr.Name)) { ps.Write("\t\t<Reference"); ps.WriteLine(" Include = \"{0}\">", refr.Name); ps.WriteLine("\t\t\t<Name>{0}</Name>", refr.Name); // TODO: Allow reference to *.exe files ps.WriteLine("\t\t\t<HintPath>{0}</HintPath>", Helper.MakePathRelativeTo(project.FullPath, refr.Path + "\\" + refr.Name + ".dll")); ps.WriteLine("\t\t</Reference>"); } } ps.WriteLine("\t</ItemGroup>"); //Project References ps.WriteLine("\t<ItemGroup>"); foreach (ReferenceNode refr in project.References) { if (solution.ProjectsTable.ContainsKey(refr.Name)) { ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name]; // TODO: Allow reference to visual basic projects ps.WriteLine("\t\t<ProjectReference Include=\"{0}\">", Helper.MakePathRelativeTo(project.FullPath, Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj"))); //<ProjectReference Include="..\..\RealmForge\Utility\RealmForge.Utility.csproj"> ps.WriteLine("\t\t\t<Name>{0}</Name>", refProject.Name); // <Name>RealmForge.Utility</Name> ps.WriteLine("\t\t\t<Project>{{{0}}}</Project>", refProject.Guid.ToString().ToUpper()); // <Project>{6880D1D3-69EE-461B-B841-5319845B20D3}</Project> ps.WriteLine("\t\t\t<Package>{0}</Package>", toolInfo.Guid.ToString().ToUpper()); // <Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package> ps.WriteLine("\t\t</ProjectReference>"); //</ProjectReference> } else { } } ps.WriteLine("\t</ItemGroup>"); // ps.WriteLine("\t\t</Build>"); ps.WriteLine("\t<ItemGroup>"); // ps.WriteLine("\t\t\t<Include>"); foreach (string file in project.Files) { ps.Write("\t\t<{0} ", project.Files.GetBuildAction(file)); ps.WriteLine(" Include =\"{0}\">", file.Replace(".\\", "")); ps.WriteLine("\t\t\t<SubType>Code</SubType>"); ps.WriteLine("\t\t</{0}>", project.Files.GetBuildAction(file)); // ps.WriteLine("\t\t\t\t<File"); // ps.WriteLine("\t\t\t\t\tRelPath = \"{0}\"", file.Replace(".\\", "")); // ps.WriteLine("\t\t\t\t\tSubType = \"Code\""); // ps.WriteLine("\t\t\t\t\tBuildAction = \"{0}\"", project.Files.GetBuildAction(file)); // ps.WriteLine("\t\t\t\t/>"); } // ps.WriteLine("\t\t\t</Include>"); ps.WriteLine("\t</ItemGroup>"); ps.WriteLine("\t<Import Project=\"$(MSBuildBinPath)\\Microsoft.CSHARP.Targets\" />"); ps.WriteLine("\t<PropertyGroup>"); ps.WriteLine("\t\t<PreBuildEvent>"); ps.WriteLine("\t\t</PreBuildEvent>"); ps.WriteLine("\t\t<PostBuildEvent>"); ps.WriteLine("\t\t</PostBuildEvent>"); ps.WriteLine("\t</PropertyGroup>"); // ps.WriteLine("\t</{0}>", toolInfo.XMLTag); ps.WriteLine("</Project>"); } #endregion #region User File ps = new StreamWriter(projectFile + ".user"); using ( ps ) { ps.WriteLine("<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"); //ps.WriteLine( "<VisualStudioProject>" ); //ps.WriteLine("\t<{0}>", toolInfo.XMLTag); //ps.WriteLine("\t\t<Build>"); ps.WriteLine("\t<PropertyGroup>"); //ps.WriteLine("\t\t\t<Settings ReferencePath=\"{0}\">", MakeRefPath(project)); ps.WriteLine("\t\t<Configuration Condition=\" '$(Configuration)' == '' \">Debug</Configuration>"); ps.WriteLine("\t\t<Platform Condition=\" '$(Platform)' == '' \">AnyCPU</Platform>"); ps.WriteLine("\t\t<ReferencePath>{0}</ReferencePath>", MakeRefPath(project)); ps.WriteLine("\t\t<LastOpenVersion>{0}</LastOpenVersion>", this.ProductVersion); ps.WriteLine("\t\t<ProjectView>ProjectFiles</ProjectView>"); ps.WriteLine("\t\t<ProjectTrust>0</ProjectTrust>"); ps.WriteLine("\t</PropertyGroup>"); foreach (ConfigurationNode conf in project.Configurations) { ps.Write("\t<PropertyGroup"); ps.Write(" Condition = \" '$(Configuration)|$(Platform)' == '{0}|AnyCPU' \"", conf.Name); ps.WriteLine(" />"); } //ps.WriteLine("\t\t\t</Settings>"); //ps.WriteLine("\t\t</Build>"); //ps.WriteLine("\t</{0}>", toolInfo.XMLTag); //ps.WriteLine("</VisualStudioProject>"); ps.WriteLine("</Project>"); } #endregion kernel.CurrentWorkingDirectory.Pop(); }