Inheritance: DataNode
コード例 #1
0
ファイル: NAntTarget.cs プロジェクト: CassieEllen/opensim
        private static string BuildReference(SolutionNode solution, ProjectNode currentProject, ReferenceNode refr)
        {

            if (!String.IsNullOrEmpty(refr.Path))
            {
                return refr.Path;
            }
            
            if (solution.ProjectsTable.ContainsKey(refr.Name))
            {
                ProjectNode projectRef = (ProjectNode) solution.ProjectsTable[refr.Name];
                string finalPath =
                    Helper.NormalizePath(refr.Name + GetProjectExtension(projectRef), '/');
                return finalPath;
            }

            ProjectNode project = (ProjectNode) refr.Parent;

            // Do we have an explicit file reference?
            string fileRef = FindFileReference(refr.Name, project);
            if (fileRef != null)
            {
                return fileRef;
            }

            // Is there an explicit path in the project ref?
            if (refr.Path != null)
            {
                return Helper.NormalizePath(refr.Path + "/" + refr.Name + GetProjectExtension(project), '/');
            }

            // No, it's an extensionless GAC ref, but nant needs the .dll extension anyway
            return refr.Name + ".dll";
        }
コード例 #2
0
 /// <summary>
 /// Gets the XML doc file.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="conf">The conf.</param>
 /// <returns></returns>
 public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
 {
     if( conf == null )
     {
         throw new ArgumentNullException("conf");
     }
     if( project == null )
     {
         throw new ArgumentNullException("project");
     }
     string docFile = (string)conf.Options["XmlDocFile"];
     //			if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
     //			{
     //				return Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
     //			}
     return docFile;
 }
コード例 #3
0
 /// <summary>
 /// Gets the XML doc file.
 /// </summary>
 /// <param name="project">The project.</param>
 /// <param name="conf">The conf.</param>
 /// <returns></returns>
 public static string GenerateXmlDocFile(ProjectNode project, ConfigurationNode conf)
 {
     if( conf == null )
     {
         throw new ArgumentNullException("conf");
     }
     if( project == null )
     {
         throw new ArgumentNullException("project");
     }
     string docFile = (string)conf.Options["XmlDocFile"];
     if(docFile != null && docFile.Length == 0)//default to assembly name if not specified
     {
         return "False";
     }
     return "True";
 }
コード例 #4
0
 // This converts a path relative to the path of a project to
 // a path relative to the solution path.
 private string NicePath(ProjectNode proj, string path)
 {
     string res;
     SolutionNode solution = (SolutionNode)proj.Parent;
     res = Path.Combine(Helper.NormalizePath(proj.FullPath, '/'), Helper.NormalizePath(path, '/'));
     res = Helper.NormalizePath(res, '/');
     res = res.Replace("/./", "/");
     while (res.IndexOf("/../") >= 0)
     {
         int a = res.IndexOf("/../");
         int b = res.LastIndexOf("/", a - 1);
         res = res.Remove(b, a - b + 3);
     }
     res = Helper.MakePathRelativeTo(solution.FullPath, res);
     if (res.StartsWith("./"))
         res = res.Substring(2, res.Length - 2);
     res = Helper.NormalizePath(res, '/');
     return res;
 }
コード例 #5
0
        private void WriteProjectFiles(StreamWriter f, SolutionNode solution, ProjectNode project)
        {
            // Write list of source code files
            f.WriteLine("SOURCES_{0} = \\", project.Name);
            foreach (string file in project.Files)
                if (project.Files.GetBuildAction(file) == BuildAction.Compile)
                    f.WriteLine("\t{0} \\", NicePath(project, file));
            f.WriteLine();

            // Write list of resource files
            f.WriteLine("RESOURCES_{0} = \\", project.Name);
            foreach (string file in project.Files)
                if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource)
                {
                    string path = NicePath(project, file);
                    f.WriteLine("\t-resource:{0},{1} \\", path, Path.GetFileName(path));
                }
            f.WriteLine();

            // There's also Content and None in BuildAction.
            // What am I supposed to do with that?
        }
コード例 #6
0
ファイル: NAntTarget.cs プロジェクト: CassieEllen/opensim
 private static string GetProjectExtension(ProjectNode project)
 {
     string extension = ".dll";
     if (project.Type == ProjectType.Exe || project.Type == ProjectType.WinExe)
     {
         extension = ".exe";
     }
     return extension;
 }
コード例 #7
0
ファイル: NAntTarget.cs プロジェクト: CassieEllen/opensim
		private void WriteProject(SolutionNode solution, ProjectNode project)
		{
            string projFile = Helper.MakeFilePath(project.FullPath, project.Name + GetProjectExtension(project), "build");
			StreamWriter ss = new StreamWriter(projFile);

			m_Kernel.CurrentWorkingDirectory.Push();
			Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
			bool hasDoc = false;

			using (ss)
			{
				ss.WriteLine("<?xml version=\"1.0\" ?>");
				ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
				ss.WriteLine("	  <target name=\"{0}\">", "build");
				ss.WriteLine("		  <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
				ss.WriteLine("		  <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");

				ss.Write("		  <csc ");
				ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
				ss.Write(" debug=\"{0}\"", "${build.debug}");
				ss.Write(" platform=\"${build.platform}\"");


				foreach (ConfigurationNode conf in project.Configurations)
				{
					if (conf.Options.KeyFile != "")
					{
						ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
						break;
					}
				}
				foreach (ConfigurationNode conf in project.Configurations)
				{
					ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
					break;
				}
				foreach (ConfigurationNode conf in project.Configurations)
				{
					ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors);
					break;
				}
				foreach (ConfigurationNode conf in project.Configurations)
				{
					ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
					break;
				}
				foreach (ConfigurationNode conf in project.Configurations)
				{
					ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
					break;
				}

				ss.Write(" main=\"{0}\"", project.StartupObject);

				foreach (ConfigurationNode conf in project.Configurations)
				{
					if (GetXmlDocFile(project, conf) != "")
					{
						ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
						hasDoc = true;
					}
					break;
				}
				ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
				if (project.Type == ProjectType.Library)
				{
					ss.Write(".dll\"");
				}
				else
				{
					ss.Write(".exe\"");
				}
				if (project.AppIcon != null && project.AppIcon.Length != 0)
				{
					ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
				}
                // This disables a very different behavior between VS and NAnt.  With Nant,
                //    If you have using System.Xml;  it will ensure System.Xml.dll is referenced,
                //    but not in VS.  This will force the behaviors to match, so when it works
                //    in nant, it will work in VS.
                ss.Write(" noconfig=\"true\"");
                ss.WriteLine(">");
				ss.WriteLine("			  <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
				foreach (string file in project.Files)
				{
					switch (project.Files.GetBuildAction(file))
					{
						case BuildAction.EmbeddedResource:
							ss.WriteLine("				  {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
							break;
						default:
							if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
							{
								ss.WriteLine("				  <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
							}
							break;
					}
				}
				//if (project.Files.GetSubType(file).ToString() != "Code")
				//{
				//	ps.WriteLine("	  <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");					

				ss.WriteLine("			  </resources>");
				ss.WriteLine("			  <sources failonempty=\"true\">");
				foreach (string file in project.Files)
				{
					switch (project.Files.GetBuildAction(file))
					{
						case BuildAction.Compile:
							ss.WriteLine("				  <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
							break;
						default:
							break;
					}
				}
				ss.WriteLine("			  </sources>");
				ss.WriteLine("			  <references basedir=\"${project::get-base-directory()}\">");
				ss.WriteLine("				  <lib>");
				ss.WriteLine("					  <include name=\"${project::get-base-directory()}\" />");
                foreach(ReferencePathNode refPath in project.ReferencePaths)
                {
                    ss.WriteLine("					  <include name=\"${project::get-base-directory()}/" + refPath.Path.TrimEnd('/', '\\') + "\" />");
                }
				ss.WriteLine("				  </lib>");
				foreach (ReferenceNode refr in project.References)
				{
					string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, project, refr)), '/');
                    if (refr.Path != null) {
                        if (ExtensionSpecified(refr.Name))
                        {
                            ss.WriteLine ("                <include name=\"" + path + refr.Name + "\"/>");
                        }
                        else
                        {
                            ss.WriteLine ("                <include name=\"" + path + refr.Name + ".dll\"/>");
                        }
                    }
                    else
                    {
                        ss.WriteLine ("                <include name=\"" + path + "\" />");
                    }
				}
				ss.WriteLine("			  </references>");

				ss.WriteLine("		  </csc>");

				foreach (ConfigurationNode conf in project.Configurations)
                {
                    if (!String.IsNullOrEmpty(conf.Options.OutputPath))
                    {
                        string targetDir = Helper.NormalizePath(conf.Options.OutputPath, '/');

                        ss.WriteLine("        <echo message=\"Copying from [${project::get-base-directory()}/${build.dir}/] to [${project::get-base-directory()}/" + targetDir + "\" />");

                        ss.WriteLine("        <mkdir dir=\"${project::get-base-directory()}/" + targetDir + "\"/>");

                        ss.WriteLine("        <copy todir=\"${project::get-base-directory()}/" + targetDir + "\">");
                        ss.WriteLine("            <fileset basedir=\"${project::get-base-directory()}/${build.dir}/\" >");
                        ss.WriteLine("                <include name=\"*.dll\"/>");
                        ss.WriteLine("                <include name=\"*.exe\"/>");
                        ss.WriteLine("                <include name=\"*.mdb\" if='${build.debug}'/>");
                        ss.WriteLine("                <include name=\"*.pdb\" if='${build.debug}'/>");
                        ss.WriteLine("            </fileset>");
                        ss.WriteLine("        </copy>");
                        break;
                    }
                }

				ss.WriteLine("	  </target>");

				ss.WriteLine("	  <target name=\"clean\">");
				ss.WriteLine("		  <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
				ss.WriteLine("		  <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
				ss.WriteLine("	  </target>");

				ss.WriteLine("	  <target name=\"doc\" description=\"Creates documentation.\">");
				if (hasDoc)
				{
					ss.WriteLine("		  <property name=\"doc.target\" value=\"\" />");
					ss.WriteLine("		  <if test=\"${platform::is-unix()}\">");
					ss.WriteLine("			  <property name=\"doc.target\" value=\"Web\" />");
					ss.WriteLine("		  </if>");
					ss.WriteLine("		  <ndoc failonerror=\"false\" verbose=\"true\">");
					ss.WriteLine("			  <assemblies basedir=\"${project::get-base-directory()}\">");
					ss.Write("				  <include name=\"${build.dir}/${project::get-name()}");
					if (project.Type == ProjectType.Library)
					{
						ss.WriteLine(".dll\" />");
					}
					else
					{
						ss.WriteLine(".exe\" />");
					}

					ss.WriteLine("			  </assemblies>");
					ss.WriteLine("			  <summaries basedir=\"${project::get-base-directory()}\">");
					ss.WriteLine("				  <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
					ss.WriteLine("			  </summaries>");
					ss.WriteLine("			  <referencepaths basedir=\"${project::get-base-directory()}\">");
					ss.WriteLine("				  <include name=\"${build.dir}\" />");
					//					foreach(ReferenceNode refr in project.References)
					//					{
					//						string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
					//						if (path != "")
					//						{
					//							ss.WriteLine("				  <include name=\"{0}\" />", path);
					//						}
					//					}
					ss.WriteLine("			  </referencepaths>");
					ss.WriteLine("			  <documenters>");
					ss.WriteLine("				  <documenter name=\"MSDN\">");
					ss.WriteLine("					  <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/${project::get-name()}\" />");
					ss.WriteLine("					  <property name=\"OutputTarget\" value=\"${doc.target}\" />");
					ss.WriteLine("					  <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
					ss.WriteLine("					  <property name=\"IncludeFavorites\" value=\"False\" />");
					ss.WriteLine("					  <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
					ss.WriteLine("					  <property name=\"SplitTOCs\" value=\"False\" />");
					ss.WriteLine("					  <property name=\"DefaulTOC\" value=\"\" />");
					ss.WriteLine("					  <property name=\"ShowVisualBasic\" value=\"True\" />");
					ss.WriteLine("					  <property name=\"AutoDocumentConstructors\" value=\"True\" />");
					ss.WriteLine("					  <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
					ss.WriteLine("					  <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
					ss.WriteLine("					  <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
					ss.WriteLine("					  <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
					ss.WriteLine("					  <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
					ss.WriteLine("					  <property name=\"DocumentInternals\" value=\"False\" />");
					ss.WriteLine("					  <property name=\"DocumentPrivates\" value=\"False\" />");
					ss.WriteLine("					  <property name=\"DocumentProtected\" value=\"True\" />");
					ss.WriteLine("					  <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
					ss.WriteLine("					  <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
					ss.WriteLine("				  </documenter>");
					ss.WriteLine("			  </documenters>");
					ss.WriteLine("		  </ndoc>");
				}
				ss.WriteLine("	  </target>");
				ss.WriteLine("</project>");
			}
			m_Kernel.CurrentWorkingDirectory.Pop();
		}
コード例 #8
0
        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>");
                string refPath = ((ReferencePathNode) project.ReferencePaths[0]).Path;

                foreach (ReferenceNode refr in project.References)
                {
                    if (!solution.ProjectsTable.ContainsKey(refr.Name))
                    {
                        ps.Write("    <Reference");
                        ps.Write(" Include=\"");
                        ps.Write(refr.Name);

                        ps.WriteLine("\" >");

                        string path;

                        if( refr.Name.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase ))
                        {
                            path = Helper.NormalizePath(Path.Combine( refPath, refr.Name), '\\');
                        }
                        else
                        {
                            path = refr.Name + ".dll";
                        }

                        // TODO: Allow reference to *.exe files
                        ps.WriteLine("      <HintPath>{0}</HintPath>", path );
                        ps.WriteLine("      <Private>{0}</Private>", refr.LocalCopy);
                        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
                        string path =
                            Helper.MakePathRelativeTo(project.FullPath,
                                                      Helper.MakeFilePath(refProject.FullPath, refProject.Name, "csproj"));
                        ps.WriteLine("    <ProjectReference Include=\"{0}\">", path );
                        //<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("\t\t\t<Private>{0}</Private>", refr.LocalCopy);
                        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>");

                if (projectFile.Contains( "OpenSim.csproj" ))
                {
                    ps.WriteLine("    <StartArguments>-loginserver -sandbox -accounts</StartArguments>");
                }

                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("</Project>");
            }
            #endregion

            kernel.CurrentWorkingDirectory.Pop();
        }
コード例 #9
0
		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();
		}
コード例 #10
0
		private void WriteProject(SolutionNode solution, ProjectNode project)
		{
			string csComp = "Mcs";
			string netRuntime = "Mono";
			if(project.Runtime == ClrRuntime.Microsoft)
			{
				csComp = "Csc";
				netRuntime = "MsNet";
			}

			string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
			StreamWriter ss = new StreamWriter(projFile);

			m_Kernel.CurrentWorkingDirectory.Push();
			Helper.SetCurrentDir(Path.GetDirectoryName(projFile));

			using(ss)
			{
				ss.WriteLine(
					"<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" ctype=\"DotNetProject\">",
					project.Name,
					project.RootNamespace
					);
				
								int count = 0;
				
				ss.WriteLine("  <Configurations active=\"{0}\">", solution.ActiveConfig);

				foreach(ConfigurationNode conf in project.Configurations)
				{
					ss.WriteLine("    <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name);
					ss.Write("      <Output");
					ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString())));
					ss.Write(" assembly=\"{0}\"", project.AssemblyName);
					ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
					//ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
					//ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
					if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
					{
						ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
					}
					else
					{
						ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
					}
					if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
					{
						ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
					}
					else
					{
						ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
					}
					ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
					ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
					ss.WriteLine(" />");
					
					ss.Write("      <Build");
					ss.Write(" debugmode=\"True\"");
					if (project.Type == ProjectType.WinExe)
					{
						ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString());
					}
					else
					{
						ss.Write(" target=\"{0}\"", project.Type);
					}
					ss.WriteLine(" />");
					
					ss.Write("      <Execution");
					ss.Write(" runwithwarnings=\"{0}\"", !conf.Options.WarningsAsErrors);
					ss.Write(" consolepause=\"True\"");
					ss.Write(" runtime=\"{0}\"", netRuntime);
                    ss.Write(" clr-version=\"Net_2_0\"");
					ss.WriteLine(" />");
					
					ss.Write("      <CodeGeneration");
					ss.Write(" compiler=\"{0}\"", csComp);
					ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
					ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
					ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
					ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
					ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
					ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
					ss.Write(" mainclass=\"{0}\"", project.StartupObject);
					ss.Write(" target=\"{0}\"", project.Type);
					ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
					ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
					ss.Write(" win32Icon=\"{0}\"", project.AppIcon);
					ss.Write(" ctype=\"CSharpCompilerParameters\"");
					ss.WriteLine(" />");
					ss.WriteLine("    </Configuration>");

					count++;
				}                
				ss.WriteLine("  </Configurations>");

				ss.Write("  <DeploymentInformation");
				ss.Write(" target=\"\"");
				ss.Write(" script=\"\"");
				ss.Write(" strategy=\"File\"");
				ss.WriteLine(">");
				ss.WriteLine("    <excludeFiles />");
				ss.WriteLine("  </DeploymentInformation>");
				
				ss.WriteLine("  <Contents>");
				foreach(string file in project.Files)
				{
					string buildAction = "Compile";
					switch(project.Files.GetBuildAction(file))
					{
						case BuildAction.None:
							buildAction = "Nothing";
							break;

						case BuildAction.Content:
							buildAction = "Exclude";
							break;

						case BuildAction.EmbeddedResource:
							buildAction = "EmbedAsResource";
							break;

						default:
							buildAction = "Compile";
							break;
					}

					// Sort of a hack, we try and resolve the path and make it relative, if we can.
					string filePath = PrependPath(file);
					ss.WriteLine("    <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\" dependson=\"\" data=\"\" />", filePath, buildAction);
				}
				ss.WriteLine("  </Contents>");

				ss.WriteLine("  <References>");
				foreach(ReferenceNode refr in project.References)
				{
					ss.WriteLine("    {0}", BuildReference(solution, refr));
				}
				ss.WriteLine("  </References>");


				ss.WriteLine("</Project>");
			}

			m_Kernel.CurrentWorkingDirectory.Pop();
		}
コード例 #11
0
        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);
        }
コード例 #12
0
 private string ProjectOutput(ProjectNode project, ConfigurationNode config)
 {
     string filepath;
     filepath = Helper.MakeFilePath((string)config.Options["OutputPath"],
             project.AssemblyName, ProjectTypeToExtension(project.Type));
     return NicePath(project, filepath);
 }
コード例 #13
0
        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();
        }
コード例 #14
0
 private void WriteProjectReferences(StreamWriter f, SolutionNode solution, ProjectNode project)
 {
     f.WriteLine("REFERENCES_{0} = \\", project.Name);
     foreach (ReferenceNode refr in project.References)
     {
         string path;
         // Project references change with configurations.
         if (solution.ProjectsTable.Contains(refr.Name))
             continue;
         path = FindFileReference(refr.Name, project);
         if (path != null)
             f.WriteLine("\t-r:{0} \\", path);
         else
             f.WriteLine("\t-r:{0} \\", refr.Name);
     }
     f.WriteLine();
 }
コード例 #15
0
 private void WriteProjectDependencies(StreamWriter f, SolutionNode solution, ProjectNode project)
 {
     f.WriteLine("DEPENDENCIES_{0} = \\", project.Name);
     f.WriteLine("\t$(SOURCES_{0}) \\", project.Name);
     foreach (string file in project.Files)
         if (project.Files.GetBuildAction(file) == BuildAction.EmbeddedResource)
             f.WriteLine("\t{0} \\", NicePath(project, file));
     f.WriteLine();
 }
コード例 #16
0
ファイル: VSGenericTarget.cs プロジェクト: RavenB/gridsearch
		private void WriteProject(SolutionNode solution, StreamWriter ss, ProjectNode project)
		{
			WriteProject(ss, solution, project.Language, project.Guid, project.Name, project.FullPath);
		}
コード例 #17
0
ファイル: VSGenericTarget.cs プロジェクト: RavenB/gridsearch
		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=\"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("  </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)
                    {
                        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"));
					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 (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>");
						}
						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
						{
							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(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))
									ps.WriteLine("      <DependentUpon>{0}</DependentUpon>", Path.GetFileName(file_name));
								else if (File.Exists(file_name + ".resx"))
									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"))
                                        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();
		}
コード例 #18
0
ファイル: NAntTarget.cs プロジェクト: aurora-sim/Aurora-Libs
		private void WriteProject(SolutionNode solution, ProjectNode project)
		{
			string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
			StreamWriter ss = new StreamWriter(projFile);

			m_Kernel.CurrentWorkingDirectory.Push();
			Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
			bool hasDoc = false;

			using(ss)
			{
				ss.WriteLine("<?xml version=\"1.0\" ?>");
				ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
				ss.WriteLine("    <target name=\"{0}\">", "build");
				ss.WriteLine("        <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
				ss.WriteLine("        <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");				
				
				ss.Write("        <csc");
				ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
				ss.Write(" debug=\"{0}\"", "${build.debug}");
				ss.Write(" unsafe=\"{0}\"", "true");
				foreach(ConfigurationNode conf in project.Configurations)
				{
					if (GetXmlDocFile(project, conf) !="")
					{
						ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
						hasDoc = true;
					}
					break;
				}
				ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
				if (project.Type == ProjectType.Library)
				{
					ss.Write(".dll\"");
				}
				else
				{
					ss.Write(".exe\"");
				}
				if(project.AppIcon != null && project.AppIcon.Length != 0)
				{
					ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon,'/'));
				}
				ss.WriteLine(">");
				ss.WriteLine("            <sources failonempty=\"true\">");
				foreach(string file in project.Files)
				{
					switch(project.Files.GetBuildAction(file))
					{
						case BuildAction.Compile:
							ss.WriteLine("                <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
							break;
						default:
							break;
					}
				}
				ss.WriteLine("            </sources>");
				ss.WriteLine("            <references basedir=\"${project::get-base-directory()}\">");
				ss.WriteLine("                <lib>");
				ss.WriteLine("                    <include name=\"${project::get-base-directory()}\" />");
				ss.WriteLine("                </lib>");
				foreach(ReferenceNode refr in project.References)
				{
					ss.WriteLine("                <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr))+"\" />", '/'));
				}
				ss.WriteLine("            </references>");
				ss.WriteLine("            <resources>");
				foreach(string file in project.Files)
				{
					switch(project.Files.GetBuildAction(file))
					{
						case BuildAction.EmbeddedResource:
							ss.WriteLine("                {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
							break;
						default:
							break;
					}
				}
				ss.WriteLine("            </resources>");
				ss.WriteLine("        </csc>");
				ss.WriteLine("    </target>");

				ss.WriteLine("    <target name=\"clean\">");
				ss.WriteLine("        <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
				ss.WriteLine("        <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
				ss.WriteLine("    </target>");

				ss.WriteLine("    <target name=\"doc\" description=\"Creates documentation.\">");
				if (hasDoc)
				{
					ss.WriteLine("        <property name=\"doc.target\" value=\"\" />");
					ss.WriteLine("        <if test=\"${platform::is-unix()}\">");
					ss.WriteLine("            <property name=\"doc.target\" value=\"Web\" />");
					ss.WriteLine("        </if>");
					ss.WriteLine("        <ndoc failonerror=\"true\" verbose=\"true\">");
					ss.WriteLine("            <assemblies basedir=\"${project::get-base-directory()}/${build.dir}\">");
					ss.Write("                <include name=\"${project::get-name()}");
					if (project.Type == ProjectType.Library)
					{
						ss.WriteLine(".dll\" />");
					}
					else
					{
						ss.WriteLine(".exe\" />");
					}

					ss.WriteLine("            </assemblies>");
					ss.WriteLine("            <summaries basedir=\"${project::get-base-directory()}/${build.dir}\">");
					ss.WriteLine("                <include name=\"${project::get-name()}.xml\"/>");
					ss.WriteLine("            </summaries>");
					ss.WriteLine("            <referencepaths basedir=\"${project::get-base-directory()}\">");
					ss.WriteLine("                <include name=\"${build.dir}\" />");
					ss.WriteLine("            </referencepaths>");
					ss.WriteLine("            <documenters>");
					ss.WriteLine("                <documenter name=\"MSDN\">");
					ss.WriteLine("                    <property name=\"OutputDirectory\" value=\"${project::get-base-directory()}/${build.dir}/doc/\" />");
					ss.WriteLine("                    <property name=\"OutputTarget\" value=\"${doc.target}\" />");
					ss.WriteLine("                    <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
					ss.WriteLine("                    <property name=\"IncludeFavorites\" value=\"False\" />");
					ss.WriteLine("                    <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
					ss.WriteLine("                    <property name=\"SplitTOCs\" value=\"False\" />");
					ss.WriteLine("                    <property name=\"DefaulTOC\" value=\"\" />");
					ss.WriteLine("                    <property name=\"ShowVisualBasic\" value=\"True\" />");
					ss.WriteLine("                    <property name=\"AutoDocumentConstructors\" value=\"True\" />");
					ss.WriteLine("                    <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
					ss.WriteLine("                    <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
					ss.WriteLine("                    <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
					ss.WriteLine("                    <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
					ss.WriteLine("                    <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
					ss.WriteLine("                    <property name=\"DocumentInternals\" value=\"False\" />");
					ss.WriteLine("                    <property name=\"DocumentPrivates\" value=\"False\" />");
					ss.WriteLine("                    <property name=\"DocumentProtected\" value=\"True\" />");
					ss.WriteLine("                    <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
					ss.WriteLine("                    <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
					ss.WriteLine("                </documenter>");
					ss.WriteLine("            </documenters>");
					ss.WriteLine("        </ndoc>");
				}
				ss.WriteLine("    </target>");
				ss.WriteLine("</project>");
			}                
			m_Kernel.CurrentWorkingDirectory.Pop();
		}
コード例 #19
0
        public int CompareTo(object obj)
        {
            ProjectNode that = (ProjectNode)obj;

            return(m_Name.CompareTo(that.m_Name));
        }
コード例 #20
0
 // Returns true if two configs in one project have the same output.
 private bool ProjectClashes(ProjectNode project)
 {
     foreach (ConfigurationNode conf1 in project.Configurations)
         foreach (ConfigurationNode conf2 in project.Configurations)
             if (ProjectOutput(project, conf1) == ProjectOutput(project, conf2) && conf1 != conf2)
             {
                 m_Kernel.Log.Write("Warning: Configurations {0} and {1} for project {2} output the same file",
                         conf1.Name, conf2.Name, project.Name);
                 m_Kernel.Log.Write("Warning: I'm going to use some timestamps(extra empty files).");
                 return true;
             }
     return false;
 }
コード例 #21
0
        /// <summary>
        /// Gets the XML doc file.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="conf">The conf.</param>
        /// <returns></returns>
        public static string GetXmlDocFile(ProjectNode project, ConfigurationNode conf)
        {
            if( conf == null )
            {
                throw new ArgumentNullException("conf");
            }
            if( project == null )
            {
                throw new ArgumentNullException("project");
            }
            //			if(!(bool)conf.Options["GenerateXmlDocFile"]) //default to none, if the generate option is false
            //			{
            //				return string.Empty;
            //			}

            //default to "AssemblyName.xml"
            //string defaultValue = Path.GetFileNameWithoutExtension(project.AssemblyName) + ".xml";
            //return (string)conf.Options["XmlDocFile", defaultValue];

            //default to no XmlDocFile file
            return (string)conf.Options["XmlDocFile", ""];
        }
コード例 #22
0
        private void WriteProject(StreamWriter f, SolutionNode solution, ProjectNode project)
        {
            f.WriteLine("# This is for project {0}", project.Name);
            f.WriteLine();

            WriteProjectFiles(f, solution, project);
            WriteProjectReferences(f, solution, project);
            WriteProjectDependencies(f, solution, project);

            bool clash = ProjectClashes(project);

            foreach (ConfigurationNode conf in project.Configurations)
            {
                string outpath = ProjectOutput(project, conf);
                string filesToClean = outpath;

                if (clash)
                {
                    f.WriteLine("{0}-{1}: .{0}-{1}-timestamp", project.Name, conf.Name);
                    f.WriteLine();
                    f.Write(".{0}-{1}-timestamp: $(DEPENDENCIES_{0})", project.Name, conf.Name);
                }
                else
                {
                    f.WriteLine("{0}-{1}: {2}", project.Name, conf.Name, outpath);
                    f.WriteLine();
                    f.Write("{2}: $(DEPENDENCIES_{0})", project.Name, conf.Name, outpath);
                }
                // Dependencies on other projects.
                foreach (ReferenceNode refr in project.References)
                    if (solution.ProjectsTable.Contains(refr.Name))
                    {
                        ProjectNode refProj = (ProjectNode)solution.ProjectsTable[refr.Name];
                        if (ProjectClashes(refProj))
                            f.Write(" .{0}-{1}-timestamp", refProj.Name, conf.Name);
                        else
                            f.Write(" {0}", ProjectOutput(refProj, conf));
                    }
                f.WriteLine();

                // make directory for output.
                if (Path.GetDirectoryName(outpath) != "")
                {
                    f.WriteLine("\tmkdir -p {0}", Path.GetDirectoryName(outpath));
                }
                // mcs command line.
                f.Write("\tgmcs", project.Name);
                f.Write(" -warn:{0}", conf.Options["WarningLevel"]);
                if ((bool)conf.Options["DebugInformation"])
                    f.Write(" -debug");
                if ((bool)conf.Options["AllowUnsafe"])
                    f.Write(" -unsafe");
                if ((bool)conf.Options["CheckUnderflowOverflow"])
                    f.Write(" -checked");
                if (project.StartupObject != "")
                    f.Write(" -main:{0}", project.StartupObject);
                if ((string)conf.Options["CompilerDefines"] != "")
                {
                    f.Write(" -define:\"{0}\"", conf.Options["CompilerDefines"]);
                }

                f.Write(" -target:{0} -out:{1}", ProjectTypeToTarget(project.Type), outpath);

                // Build references to other projects. Now that sux.
                // We have to reference the other project in the same conf.
                foreach (ReferenceNode refr in project.References)
                    if (solution.ProjectsTable.Contains(refr.Name))
                    {
                        ProjectNode refProj;
                        refProj = (ProjectNode)solution.ProjectsTable[refr.Name];
                        f.Write(" -r:{0}", ProjectOutput(refProj, conf));
                    }

                f.Write(" $(REFERENCES_{0})", project.Name);
                f.Write(" $(RESOURCES_{0})", project.Name);
                f.Write(" $(SOURCES_{0})", project.Name);
                f.WriteLine();

                // Copy references with localcopy.
                foreach (ReferenceNode refr in project.References)
                    if (refr.LocalCopy)
                    {
                        string outPath, srcPath, destPath;
                        outPath = Helper.NormalizePath((string)conf.Options["OutputPath"]);
                        if (solution.ProjectsTable.Contains(refr.Name))
                        {
                            ProjectNode refProj;
                            refProj = (ProjectNode)solution.ProjectsTable[refr.Name];
                            srcPath = ProjectOutput(refProj, conf);
                            destPath = Path.Combine(outPath, Path.GetFileName(srcPath));
                            destPath = NicePath(project, destPath);
                            if (srcPath != destPath)
                            {
                                f.WriteLine("\tcp -f {0} {1}", srcPath, destPath);
                                filesToClean += " " + destPath;
                            }
                            continue;
                        }
                        srcPath = FindFileReference(refr.Name, project);
                        if (srcPath != null)
                        {
                            destPath = Path.Combine(outPath, Path.GetFileName(srcPath));
                            destPath = NicePath(project, destPath);
                            f.WriteLine("\tcp -f {0} {1}", srcPath, destPath);
                            filesToClean += " " + destPath;
                        }
                    }

                if (clash)
                {
                    filesToClean += String.Format(" .{0}-{1}-timestamp", project.Name, conf.Name);
                    f.WriteLine("\ttouch .{0}-{1}-timestamp", project.Name, conf.Name);
                    f.Write("\trm -rf");
                    foreach (ConfigurationNode otherConf in project.Configurations)
                        if (otherConf != conf)
                            f.WriteLine(" .{0}-{1}-timestamp", project.Name, otherConf.Name);
                    f.WriteLine();
                }
                f.WriteLine();
                f.WriteLine("{0}-{1}-clean:", project.Name, conf.Name);
                f.WriteLine("\trm -rf {0}", filesToClean);
                f.WriteLine();
            }
        }
コード例 #23
0
        private void WriteProject(SolutionNode solution, ProjectNode project)
        {
            string solutionDir = Path.Combine(solution.FullPath, Path.Combine("autotools", solution.Name));
            string projectDir = Path.Combine(solutionDir, project.Name);
            string projectVersion = project.Version;
            bool hasAssemblyConfig = false;
            chkMkDir(projectDir);

            List<string>
                compiledFiles = new List<string>(),
                contentFiles = new List<string>(),
                embeddedFiles = new List<string>(),

                binaryLibs = new List<string>(),
                pkgLibs = new List<string>(),
                systemLibs = new List<string>(),
                runtimeLibs = new List<string>(),

                extraDistFiles = new List<string>(),
                localCopyTargets = new List<string>();

            // If there exists a .config file for this assembly, copy
            // it to the project folder

            // TODO: Support copying .config.osx files
            // TODO: support processing the .config file for native library deps
            string projectAssemblyName = project.Name;
            if (project.AssemblyName != null)
                projectAssemblyName = project.AssemblyName;

            if (File.Exists(Path.Combine(project.FullPath, projectAssemblyName) + ".dll.config"))
            {
                hasAssemblyConfig = true;
                System.IO.File.Copy(Path.Combine(project.FullPath, projectAssemblyName + ".dll.config"), Path.Combine(projectDir, projectAssemblyName + ".dll.config"), true);
                extraDistFiles.Add(project.AssemblyName + ".dll.config");
            }

            foreach (ConfigurationNode conf in project.Configurations)
            {
                if (conf.Options.KeyFile != string.Empty)
                {
                    // Copy snk file into the project's directory
                    // Use the snk from the project directory directly
                    string source = Path.Combine(project.FullPath, conf.Options.KeyFile);
                    string keyFile = conf.Options.KeyFile;
                    Regex re = new Regex(".*/");
                    keyFile = re.Replace(keyFile, "");

                    string dest = Path.Combine(projectDir, keyFile);
                    // Tell the user if there's a problem copying the file
                    try
                    {
                        mkdirDashP(System.IO.Path.GetDirectoryName(dest));
                        System.IO.File.Copy(source, dest, true);
                    }
                    catch (System.IO.IOException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            }

            // Copy compiled, embedded and content files into the project's directory
            foreach (string filename in project.Files)
            {
                string source = Path.Combine(project.FullPath, filename);
                string dest = Path.Combine(projectDir, filename);

                if (filename.Contains("AssemblyInfo.cs"))
                {
                    // If we've got an AssemblyInfo.cs, pull the version number from it
                    string[] sources = { source };
                    string[] args = { "" };
                    Microsoft.CSharp.CSharpCodeProvider cscp =
                        new Microsoft.CSharp.CSharpCodeProvider();

                    string tempAssemblyFile = Path.Combine(Path.GetTempPath(), project.Name + "-temp.dll");
                    System.CodeDom.Compiler.CompilerParameters cparam =
                        new System.CodeDom.Compiler.CompilerParameters(args, tempAssemblyFile);
                    
                    System.CodeDom.Compiler.CompilerResults cr =
                        cscp.CompileAssemblyFromFile(cparam, sources);

                    foreach (System.CodeDom.Compiler.CompilerError error in cr.Errors)
                        Console.WriteLine("Error! '{0}'", error.ErrorText);

                    try {
                      string projectFullName = cr.CompiledAssembly.FullName;
                      Regex verRegex = new Regex("Version=([\\d\\.]+)");
                      Match verMatch = verRegex.Match(projectFullName);
                      if (verMatch.Success)
                        projectVersion = verMatch.Groups[1].Value;
                    }catch{
                      Console.WriteLine("Couldn't compile AssemblyInfo.cs");
                    }

                    // Clean up the temp file
                    try
                    {
                        if (File.Exists(tempAssemblyFile))
                            File.Delete(tempAssemblyFile);
                    }
                    catch 
                    {
                        Console.WriteLine("Error! '{0}'", e);
                    }
                   
                }

                // Tell the user if there's a problem copying the file
                try
                {
                    mkdirDashP(System.IO.Path.GetDirectoryName(dest));
                    System.IO.File.Copy(source, dest, true);
                }
                catch (System.IO.IOException e)
                {
                    Console.WriteLine(e.Message);
                }

                switch (project.Files.GetBuildAction(filename))
                {
                    case BuildAction.Compile:
                        compiledFiles.Add(filename);
                        break;
                    case BuildAction.Content:
                        contentFiles.Add(filename);
                        extraDistFiles.Add(filename);
                        break;
                    case BuildAction.EmbeddedResource:
                        embeddedFiles.Add(filename);
                        break;
                }
            }

            // Set up references
            for (int refNum = 0; refNum < project.References.Count; refNum++)
            {
                ReferenceNode refr = project.References[refNum];
                Assembly refAssembly = Assembly.LoadWithPartialName(refr.Name);

                /* Determine which pkg-config (.pc) file refers to
                   this assembly */

                SystemPackage package = null;

                if (packagesHash.ContainsKey(refr.Name))
                {
                  package = packagesHash[refr.Name];

                }
                else
                {
                    string assemblyFullName = string.Empty;
                    if (refAssembly != null)
                        assemblyFullName = refAssembly.FullName;

                    string assemblyFileName = string.Empty;
                    if (assemblyFullName != string.Empty &&
                        assemblyFullNameToPath.ContainsKey(assemblyFullName)
                        )
                        assemblyFileName =
                          assemblyFullNameToPath[assemblyFullName];

                    if (assemblyFileName != string.Empty &&
                        assemblyPathToPackage.ContainsKey(assemblyFileName)
                        )
                        package = assemblyPathToPackage[assemblyFileName];

                }

                /* If we know the .pc file and it is not "mono"
                   (already in the path), add a -pkg: argument */

                if (package != null &&
                    package.Name != "mono" &&
                    !pkgLibs.Contains(package.Name)
                    )
                    pkgLibs.Add(package.Name);

                string fileRef =
                  FindFileReference(refr.Name, (ProjectNode)refr.Parent);

                if (refr.LocalCopy ||
                    solution.ProjectsTable.ContainsKey(refr.Name) ||
                    fileRef != null ||
                    refr.Path != null
                    )
                {

                    /* Attempt to copy the referenced lib to the
                       project's directory */

                    string filename = refr.Name + ".dll";
                    string source = filename;
                    if (refr.Path != null)
                        source = Path.Combine(refr.Path, source);
                    source = Path.Combine(project.FullPath, source);
                    string dest = Path.Combine(projectDir, filename);

                    /* Since we depend on this binary dll to build, we
                     * will add a compile- time dependency on the
                     * copied dll, and add the dll to the list of
                     * files distributed with this package
                     */

                    binaryLibs.Add(refr.Name + ".dll");
                    extraDistFiles.Add(refr.Name + ".dll");

                    // TODO: Support copying .config.osx files
                    // TODO: Support for determining native dependencies
                    if (File.Exists(source + ".config"))
                    {
                        System.IO.File.Copy(source + ".config", Path.GetDirectoryName(dest), true);
                        extraDistFiles.Add(refr.Name + ".dll.config");
                    }

                    try
                    {
                        System.IO.File.Copy(source, dest, true);
                    }
                    catch (System.IO.IOException)
                    {
                      if (solution.ProjectsTable.ContainsKey(refr.Name)){

                        /* If an assembly is referenced, marked for
                         * local copy, in the list of projects for
                         * this solution, but does not exist, put a
                         * target into the Makefile.am to build the
                         * assembly and copy it to this project's
                         * directory
                         */

                        ProjectNode sourcePrj =
                          ((solution.ProjectsTable[refr.Name]));

                        string target =
                          String.Format("{0}:\n" +
                                        "\t$(MAKE) -C ../{1}\n" +
                                        "\tln ../{2}/$@ $@\n",
                                        filename,
                                        sourcePrj.Name,
                                        sourcePrj.Name );

                        localCopyTargets.Add(target);
                      }
                    }
                }
                else if( !pkgLibs.Contains(refr.Name) )
                {
                    // Else, let's assume it's in the GAC or the lib path
                    string assemName = string.Empty;
                    int index = refr.Name.IndexOf(",");

                    if (index > 0)
                        assemName = refr.Name.Substring(0, index);
                    else
                        assemName = refr.Name;

                    m_Kernel.Log.Write(String.Format(
                    "Warning: Couldn't find an appropriate assembly " +
                    "for reference:\n'{0}'", refr.Name
                                                     ));
                    systemLibs.Add(assemName);
                }
            }

            const string lineSep = " \\\n\t";
            string compiledFilesString = string.Empty;
            if (compiledFiles.Count > 0)
                compiledFilesString =
                    lineSep + string.Join(lineSep, compiledFiles.ToArray());

            string embeddedFilesString = "";
            if (embeddedFiles.Count > 0)
                embeddedFilesString =
                    lineSep + string.Join(lineSep, embeddedFiles.ToArray());

            string contentFilesString = "";
            if (contentFiles.Count > 0)
                contentFilesString =
                    lineSep + string.Join(lineSep, contentFiles.ToArray());

            string extraDistFilesString = "";
            if (extraDistFiles.Count > 0)
                extraDistFilesString =
                    lineSep + string.Join(lineSep, extraDistFiles.ToArray());

            string pkgLibsString = "";
            if (pkgLibs.Count > 0)
                pkgLibsString =
                    lineSep + string.Join(lineSep, pkgLibs.ToArray());

            string binaryLibsString = "";
            if (binaryLibs.Count > 0)
                binaryLibsString =
                    lineSep + string.Join(lineSep, binaryLibs.ToArray());

            string systemLibsString = "";
            if (systemLibs.Count > 0)
                systemLibsString =
                    lineSep + string.Join(lineSep, systemLibs.ToArray());

            string localCopyTargetsString = "";
            if (localCopyTargets.Count > 0)
                localCopyTargetsString =
                    string.Join("\n", localCopyTargets.ToArray());

            string monoPath = "";
            foreach (string runtimeLib in runtimeLibs)
            {
                monoPath += ":`pkg-config --variable=libdir " + runtimeLib + "`";
            }

            // Add the project name to the list of transformation
            // parameters
            XsltArgumentList argList = new XsltArgumentList();
            argList.AddParam("projectName", "", project.Name);
            argList.AddParam("solutionName", "", solution.Name);
            argList.AddParam("assemblyName", "", projectAssemblyName);
            argList.AddParam("compiledFiles", "", compiledFilesString);
            argList.AddParam("embeddedFiles", "", embeddedFilesString);
            argList.AddParam("contentFiles", "", contentFilesString);
            argList.AddParam("extraDistFiles", "", extraDistFilesString);
            argList.AddParam("pkgLibs", "", pkgLibsString);
            argList.AddParam("binaryLibs", "", binaryLibsString);
            argList.AddParam("systemLibs", "", systemLibsString);
            argList.AddParam("monoPath", "", monoPath);
            argList.AddParam("localCopyTargets", "", localCopyTargetsString);
            argList.AddParam("projectVersion", "", projectVersion);
            argList.AddParam("hasAssemblyConfig", "", hasAssemblyConfig ? "true" : "");

            // Transform the templates
            transformToFile(Path.Combine(projectDir, "configure.ac"), argList, "/Autotools/ProjectConfigureAc");
            transformToFile(Path.Combine(projectDir, "Makefile.am"), argList, "/Autotools/ProjectMakefileAm");
            transformToFile(Path.Combine(projectDir, "autogen.sh"), argList, "/Autotools/ProjectAutogenSh");

            if (project.Type == Core.Nodes.ProjectType.Library)
                transformToFile(Path.Combine(projectDir, project.Name + ".pc.in"), argList, "/Autotools/ProjectPcIn");
            if (project.Type == Core.Nodes.ProjectType.Exe || project.Type == Core.Nodes.ProjectType.WinExe)
                transformToFile(Path.Combine(projectDir, project.Name.ToLower() + ".in"), argList, "/Autotools/ProjectWrapperScriptIn");
        }
コード例 #24
0
ファイル: NAntTarget.cs プロジェクト: VirtualReality/LibOMV
 private void CleanProject(ProjectNode project)
 {
     m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
     string projectFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
     Helper.DeleteIfExists(projectFile);
 }
コード例 #25
0
		private void CleanProject(ProjectNode project)
		{
			m_Kernel.Log.Write("...Cleaning project: {0}", project.Name);
			string projectFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
			Helper.DeleteIfExists(projectFile);
		}
コード例 #26
0
ファイル: MonoDevelopTarget.cs プロジェクト: N3X15/prebuild
        private void WriteProject(SolutionNode solution, ProjectNode project)
        {
            string csComp = "Mcs";
            string netRuntime = "Mono";
            if(project.Runtime == ClrRuntime.Microsoft)
            {
                csComp = "Csc";
                netRuntime = "MsNet";
            }

            string projFile = Helper.MakeFilePath(project.FullPath, project.Name, "mdp");
            StreamWriter ss = new StreamWriter(projFile);

            m_Kernel.CurrentWorkingDirectory.Push();
            Helper.SetCurrentDir(Path.GetDirectoryName(projFile));

            using(ss)
            {
                ss.WriteLine(
                    "<Project name=\"{0}\" description=\"\" standardNamespace=\"{1}\" newfilesearch=\"None\" enableviewstate=\"True\" fileversion=\"2.0\" language=\"C#\" clr-version=\"Net_2_0\" targetFramework=\"{2}\" ctype=\"DotNetProject\">",
                    project.Name,
                    project.RootNamespace,
                    project.FrameworkVersion.ToString().Replace("_",".")
                    );

                                int count = 0;

                ss.WriteLine("  <Configurations active=\"{0}\">", solution.ActiveConfig);

                foreach(ConfigurationNode conf in project.Configurations)
                {
                    ss.WriteLine("    <Configuration name=\"{0}\" ctype=\"DotNetProjectConfiguration\">", conf.Name);
                    ss.Write("      <Output");
                    ss.Write(" directory=\"{0}\"", Helper.EndPath(Helper.NormalizePath(".\\" + conf.Options["OutputPath"].ToString())));
                    ss.Write(" assembly=\"{0}\"", project.AssemblyName);
                    ss.Write(" executeScript=\"{0}\"", conf.Options["RunScript"]);
                    //ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
                    //ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
                    if (conf.Options["PreBuildEvent"] != null && conf.Options["PreBuildEvent"].ToString().Length != 0)
                    {
                        ss.Write(" executeBeforeBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PreBuildEvent"].ToString()));
                    }
                    else
                    {
                        ss.Write(" executeBeforeBuild=\"{0}\"", conf.Options["PreBuildEvent"]);
                    }
                    if (conf.Options["PostBuildEvent"] != null && conf.Options["PostBuildEvent"].ToString().Length != 0)
                    {
                        ss.Write(" executeAfterBuild=\"{0}\"", Helper.NormalizePath(conf.Options["PostBuildEvent"].ToString()));
                    }
                    else
                    {
                        ss.Write(" executeAfterBuild=\"{0}\"", conf.Options["PostBuildEvent"]);
                    }
                    ss.Write(" executeBeforeBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
                    ss.Write(" executeAfterBuildArguments=\"{0}\"", conf.Options["PreBuildEventArgs"]);
                    ss.WriteLine(" />");

                    ss.Write("      <Build");
                    ss.Write(" debugmode=\"True\"");
                    if (project.Type == ProjectType.WinExe)
                    {
                        ss.Write(" target=\"{0}\"", ProjectType.Exe.ToString());
                    }
                    else
                    {
                        ss.Write(" target=\"{0}\"", project.Type);
                    }
                    ss.WriteLine(" />");

                    ss.Write("      <Execution");
                    ss.Write(" runwithwarnings=\"{0}\"", !conf.Options.WarningsAsErrors);
                    ss.Write(" consolepause=\"True\"");
                    ss.Write(" runtime=\"{0}\"", netRuntime);
                    ss.Write(" clr-version=\"Net_2_0\"");
                    ss.WriteLine(" />");

                    ss.Write("      <CodeGeneration");
                    ss.Write(" compiler=\"{0}\"", csComp);
                    ss.Write(" warninglevel=\"{0}\"", conf.Options["WarningLevel"]);
                    ss.Write(" nowarn=\"{0}\"", conf.Options["SuppressWarnings"]);
                    ss.Write(" includedebuginformation=\"{0}\"", conf.Options["DebugInformation"]);
                    ss.Write(" optimize=\"{0}\"", conf.Options["OptimizeCode"]);
                    ss.Write(" unsafecodeallowed=\"{0}\"", conf.Options["AllowUnsafe"]);
                    ss.Write(" generateoverflowchecks=\"{0}\"", conf.Options["CheckUnderflowOverflow"]);
                    ss.Write(" mainclass=\"{0}\"", project.StartupObject);
                    ss.Write(" target=\"{0}\"", project.Type);
                    ss.Write(" definesymbols=\"{0}\"", conf.Options["CompilerDefines"]);
                    ss.Write(" generatexmldocumentation=\"{0}\"", GenerateXmlDocFile(project, conf));
                    ss.Write(" win32Icon=\"{0}\"", project.AppIcon);
                    ss.Write(" ctype=\"CSharpCompilerParameters\"");
                    ss.WriteLine(" />");
                    ss.WriteLine("    </Configuration>");

                    count++;
                }
                ss.WriteLine("  </Configurations>");

                ss.Write("  <DeploymentInformation");
                ss.Write(" target=\"\"");
                ss.Write(" script=\"\"");
                ss.Write(" strategy=\"File\"");
                ss.WriteLine(">");
                ss.WriteLine("    <excludeFiles />");
                ss.WriteLine("  </DeploymentInformation>");

                ss.WriteLine("  <Contents>");
                foreach(string file in project.Files)
                {
             					string buildAction;
                    string dependson = "";
                    string resource_id = "";
                    string copyToOutput = "";

                    switch(project.Files.GetBuildAction(file))
                    {
                        case BuildAction.None:
                            buildAction = "Nothing";
                            break;

                        case BuildAction.Content:
                            buildAction = "Exclude";
                            break;

                        case BuildAction.EmbeddedResource:
                            buildAction = "EmbedAsResource";
                            break;

                        default:
                            buildAction = "Compile";
                            break;
                    }

                    if (project.Files.GetCopyToOutput(file) != CopyToOutput.Never)
                            buildAction = "FileCopy";

                    // Sort of a hack, we try and resolve the path and make it relative, if we can.
                    string extension = Path.GetExtension(file);
                    string designer_format = string.Format(".Designer{0}", extension);

                    if (file.EndsWith(designer_format))
                    {
                        string basename = file.Substring(0, file.LastIndexOf(designer_format));
                        string[] extensions = new string[] { ".cs", ".resx", ".settings" };

                        foreach(string ext in extensions)
                        {
                            if (project.Files.Contains(basename + ext))
                            {
                                dependson = string.Format(" dependson=\"{0}{1}\"", basename, ext);
                                break;
                            }
                        }
                    }
                    if (extension == ".resx")
                    {
                        buildAction = "EmbedAsResource";
                        string basename = file.Substring(0, file.LastIndexOf(".resx"));

                        // Visual Studio type resx + form dependency
                        if (project.Files.Contains(basename + ".cs"))
                        {
                            dependson = string.Format(" dependson=\"{0}{1}\"", basename, ".cs");
                        }

                        // We need to specify a resources file name to avoid MissingManifestResourceExceptions
                        // in libraries that are built.
                        resource_id = string.Format(" resource_id=\"{0}.{1}.resources\"",
                                project.AssemblyName, basename.Replace("/", "."));
                    }

                    switch(project.Files.GetCopyToOutput(file))
                    {
                        case CopyToOutput.Always:
                            copyToOutput = string.Format(" copyToOutputDirectory=\"Always\"");
                            break;
                        case CopyToOutput.PreserveNewest:
                            copyToOutput = string.Format(" copyToOutputDirectory=\"PreserveNewest\"");
                            break;
                    }

             					// Sort of a hack, we try and resolve the path and make it relative, if we can.
             					string filePath = PrependPath(file);
                    ss.WriteLine("    <File name=\"{0}\" subtype=\"Code\" buildaction=\"{1}\"{2}{3}{4} />",
                                 filePath, buildAction, dependson, resource_id, copyToOutput);
                }
                ss.WriteLine("  </Contents>");

                ss.WriteLine("  <References>");
                foreach(ReferenceNode refr in project.References)
                {
                    ss.WriteLine("    {0}", BuildReference(solution, refr));
                }
                ss.WriteLine("  </References>");

                ss.WriteLine("</Project>");
            }

            m_Kernel.CurrentWorkingDirectory.Pop();
        }
コード例 #27
0
        private string MakeRefPath(ProjectNode project)
        {
            string ret = "";
            foreach (ReferencePathNode node in project.ReferencePaths)
            {
                try
                {
                    string fullPath = Helper.ResolvePath(node.Path);
                    if (ret.Length < 1)
                    {
                        ret = fullPath;
                    }
                    else
                    {
                        ret += ";" + fullPath;
                    }
                }
                catch (ArgumentException)
                {
                    this.kernel.Log.Write(LogType.Warning, "Could not resolve reference path: {0}", node.Path);
                }
            }

            return ret;
        }
コード例 #28
0
        private void WriteProject(SolutionNode solution, ProjectNode project)
        {
            string projFile = Helper.MakeFilePath(project.FullPath, "Include", "am");
            StreamWriter ss = new StreamWriter(projFile);
            ss.NewLine = "\n";

            m_Kernel.CurrentWorkingDirectory.Push();
            Helper.SetCurrentDir(Path.GetDirectoryName(projFile));

            using(ss)
            {
                ss.WriteLine(Helper.AssemblyFullName(project.AssemblyName, project.Type) + ":");
                ss.WriteLine("\tmkdir -p " + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/");
                foreach(string file in project.Files)
                {
                    if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
                    {
                        ss.Write("\tresgen ");
                        ss.Write(Helper.NormalizePath(Path.Combine(project.Path, file.Substring(0, file.LastIndexOf('.')) + ".resx "), '/'));
                        if (project.Files.GetResourceName(file) != "")
                        {
                            ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/'));
                        }
                        else
                        {
                            ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/'));
                        }
                    }
                }
                ss.WriteLine("\t$(CSC)\t/out:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " \\");
                ss.WriteLine("\t\t/target:" + project.Type.ToString().ToLower() + " \\");
                if (project.References.Count > 0)
                {
                    ss.Write("\t\t/reference:");
                    bool firstref = true;
                    foreach(ReferenceNode refr in project.References)
                    {
                        if (firstref)
                        {
                            firstref = false;
                        }
                        else
                        {
                            ss.Write(",");
                        }
                        ss.Write("{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(solution.FullPath, BuildReference(solution, refr)), '/'));
                    }
                    ss.WriteLine(" \\");
                }
                //ss.WriteLine("\t\tProperties/AssemblyInfo.cs \\");

                foreach(string file in project.Files)
                {
                    switch(project.Files.GetBuildAction(file))
                    {
                        case BuildAction.EmbeddedResource:
                            ss.Write("\t\t/resource:");
                            ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, file), '/') + " \\");
                            break;
                        default:
                            if (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings)
                            {
                                ss.Write("\t\t/resource:");
                                if (project.Files.GetResourceName(file) != "")
                                {
                                    ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources"), '/') + "," + project.RootNamespace + "." + project.Files.GetResourceName(file) + ".resources" + " \\");
                                }
                                else
                                {
                                    ss.WriteLine(Helper.NormalizePath(Path.Combine(project.Path, project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources"), '/') + "," + project.RootNamespace + "." + file.Substring(0, file.LastIndexOf('.')) + ".resources" + " \\");
                                }
                            }
                            break;
                    }
                }

                foreach(ConfigurationNode conf in project.Configurations)
                {
                    if (conf.Options.KeyFile !="")
                    {
                        ss.WriteLine("\t\t/keyfile:" + Helper.NormalizePath(Path.Combine(project.Path, conf.Options.KeyFile), '/') + " \\");
                        break;
                    }
                }
                foreach(ConfigurationNode conf in project.Configurations)
                {
                    if (conf.Options.AllowUnsafe)
                    {
                        ss.WriteLine("\t\t/unsafe \\");
                        break;
                    }
                }
                if (project.AppIcon != "")
                {
                    ss.WriteLine("\t\t/win32icon:" + Helper.NormalizePath(Path.Combine(project.Path, project.AppIcon), '/') + " \\");
                }

                foreach(ConfigurationNode conf in project.Configurations)
                {
                    ss.WriteLine("\t\t/define:{0}", conf.Options.CompilerDefines.Replace(';', ',') + " \\");
                    break;
                }

                foreach(ConfigurationNode conf in project.Configurations)
                {
                    if (GetXmlDocFile(project, conf) !="")
                    {
                        ss.WriteLine("\t\t/doc:" + Helper.MakePathRelativeTo(solution.FullPath, project.Path) + "/$(BUILD_DIR)/$(CONFIG)/" + project.Name + ".xml \\");
                        break;
                    }
                }
                foreach(string file in project.Files)
                {
                    switch(project.Files.GetBuildAction(file))
                    {
                        case BuildAction.Compile:
                            ss.WriteLine("\t\t\\");
                            ss.Write("\t\t" + NormalizePath(Path.Combine(Helper.MakePathRelativeTo(solution.FullPath, project.Path), file)));
                            break;
                        default:
                            break;
                    }
                }
                ss.WriteLine();
                ss.WriteLine();

                if (project.Type == ProjectType.Library)
                {
                    ss.WriteLine("install-data-local:");
                    ss.WriteLine("	echo \"$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS)\";  \\");
                    ss.WriteLine("	$(GACUTIL) /i bin/Release/" + project.Name + ".dll /f $(GACUTIL_FLAGS) || exit 1;");
                    ss.WriteLine();
                    ss.WriteLine("uninstall-local:");
                    ss.WriteLine("	echo \"$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS)\"; \\");
                    ss.WriteLine("	$(GACUTIL) /u " + project.Name + " $(GACUTIL_FLAGS) || exit 1;");
                    ss.WriteLine();
                }
                ss.WriteLine("CLEANFILES = $(BUILD_DIR)/$(CONFIG)/" + Helper.AssemblyFullName(project.AssemblyName, project.Type) + " $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".mdb $(BUILD_DIR)/$(CONFIG)/" + project.AssemblyName + ".pdb " + project.AssemblyName + ".xml");
                ss.WriteLine("EXTRA_DIST = \\");
                ss.Write("	$(FILES)");
                foreach(ConfigurationNode conf in project.Configurations)
                {
                    if (conf.Options.KeyFile != "")
                    {
                        ss.Write(" \\");
                        ss.WriteLine("\t" + conf.Options.KeyFile);
                    }
                    break;
                }
            }
            m_Kernel.CurrentWorkingDirectory.Pop();
        }
コード例 #29
0
ファイル: NAntTarget.cs プロジェクト: VirtualReality/LibOMV
        private static string FindFileReference(string refName, ProjectNode project)
        {
            foreach (ReferencePathNode refPath in project.ReferencePaths)
            {
                string fullPath = Helper.MakeFilePath(refPath.Path, refName, "dll");

                if (File.Exists(fullPath))
                {
                    return fullPath;
                }
            }

            return null;
        }
コード例 #30
0
ファイル: VSGenericTarget.cs プロジェクト: N3X15/prebuild
        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("	</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>", conf.Options["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.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>");
                        //
                    }

                    BuildAction buildAction = project.Files.GetBuildAction(filePath);

                    if (subType == SubType.Designer)
                    {
                        string tagName = "EmbeddedResource";
                        string generatorName = "ResXFileCodeGenerator";
                        switch(buildAction)
                        {
                            case BuildAction.ApplicationDefinition:
                                tagName = "ApplicationDefinition";
                                generatorName = "MSBuild:Compile";
                                break;
                            case BuildAction.Page:
                                tagName = "Page";
                                generatorName = "MSBuild:Compile";
                                break;
                        }
                        ps.WriteLine("	  <{0} Include=\"{1}\">", tagName, 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>{0}</Generator>", generatorName);
                            ps.WriteLine("		<LastGenOutput>{0}</LastGenOutput>", Path.GetFileName(autogen_name));
                            ps.WriteLine("		<SubType>" + subType + "</SubType>");
                        }

                        ps.WriteLine("	  </{0}>", tagName);
                        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();
        }
コード例 #31
0
ファイル: NAntTarget.cs プロジェクト: VirtualReality/LibOMV
        private void WriteProject(SolutionNode solution, ProjectNode project)
        {
            string projFile = Helper.MakeFilePath(project.FullPath, project.Name + (project.Type == ProjectType.Library ? ".dll" : ".exe"), "build");
            StreamWriter ss = new StreamWriter(projFile);

            m_Kernel.CurrentWorkingDirectory.Push();
            Helper.SetCurrentDir(Path.GetDirectoryName(projFile));
            bool hasDoc = false;

            using (ss)
            {
                ss.WriteLine("<?xml version=\"1.0\" ?>");
                ss.WriteLine("<project name=\"{0}\" default=\"build\">", project.Name);
                ss.WriteLine("	  <target name=\"{0}\">", "build");
                //ss.WriteLine("		  <echo message=\"Build Directory is ${project::get-base-directory()}/${build.dir}\" />");
                //ss.WriteLine("		  <mkdir dir=\"${project::get-base-directory()}/${build.dir}\" />");
                ss.WriteLine("		  <echo message=\"Build Directory is ${build.dir}\" />");
                ss.WriteLine("		  <mkdir dir=\"${build.dir}\" />");

                ss.Write("		  <csc");
                ss.Write(" target=\"{0}\"", project.Type.ToString().ToLower());
                ss.Write(" debug=\"{0}\"", "${build.debug}");
                foreach (ConfigurationNode conf in project.Configurations)
                {
                    if (conf.Options.KeyFile != "")
                    {
                        ss.Write(" keyfile=\"{0}\"", conf.Options.KeyFile);
                        break;
                    }
                }
                foreach (ConfigurationNode conf in project.Configurations)
                {
                    ss.Write(" unsafe=\"{0}\"", conf.Options.AllowUnsafe);
                    break;
                }
                foreach (ConfigurationNode conf in project.Configurations)
                {
                    ss.Write(" warnaserror=\"{0}\"", conf.Options.WarningsAsErrors);
                    break;
                }
                foreach (ConfigurationNode conf in project.Configurations)
                {
                    ss.Write(" define=\"{0}\"", conf.Options.CompilerDefines);
                    break;
                }
                foreach (ConfigurationNode conf in project.Configurations)
                {
                    ss.Write(" nostdlib=\"{0}\"", conf.Options["NoStdLib"]);
                    break;
                }

                ss.Write(" main=\"{0}\"", project.StartupObject);

                foreach (ConfigurationNode conf in project.Configurations)
                {
                    if (GetXmlDocFile(project, conf) != "")
                    {
                        //ss.Write(" doc=\"{0}\"", "${project::get-base-directory()}/${build.dir}/" + GetXmlDocFile(project, conf));
                        ss.Write(" doc=\"{0}\"", "${build.dir}/" + GetXmlDocFile(project, conf));
                        hasDoc = true;
                    }
                    break;
                }
                //ss.Write(" output=\"{0}", "${project::get-base-directory()}/${build.dir}/${project::get-name()}");
                ss.Write(" output=\"{0}", "${build.dir}/${project::get-name()}");
                if (project.Type == ProjectType.Library)
                {
                    ss.Write(".dll\"");
                }
                else
                {
                    ss.Write(".exe\"");
                }
                if (project.AppIcon != null && project.AppIcon.Length != 0)
                {
                    ss.Write(" win32icon=\"{0}\"", Helper.NormalizePath(project.AppIcon, '/'));
                }
                ss.WriteLine(">");
                ss.WriteLine("			  <resources prefix=\"{0}\" dynamicprefix=\"true\" >", project.RootNamespace);
                foreach (string file in project.Files)
                {
                    switch (project.Files.GetBuildAction(file))
                    {
                        case BuildAction.EmbeddedResource:
                            ss.WriteLine("				  {0}", "<include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
                            break;
                        default:
                            if (file.EndsWith(".resx") || (project.Files.GetSubType(file) != SubType.Code && project.Files.GetSubType(file) != SubType.Settings))
                            {
                                ss.WriteLine("				  <include name=\"{0}\" />", file.Substring(0, file.LastIndexOf('.')) + ".resx");
                            }
                            break;
                    }
                }
                //if (project.Files.GetSubType(file).ToString() != "Code")
                //{
                //	ps.WriteLine("	  <EmbeddedResource Include=\"{0}\">", file.Substring(0, file.LastIndexOf('.')) + ".resx");

                ss.WriteLine("			  </resources>");
                ss.WriteLine("			  <sources failonempty=\"true\">");
                foreach (string file in project.Files)
                {
                    switch (project.Files.GetBuildAction(file))
                    {
                        case BuildAction.Compile:
                            if (!file.EndsWith(".resx"))
                                ss.WriteLine("				  <include name=\"" + Helper.NormalizePath(PrependPath(file), '/') + "\" />");
                            break;
                        default:
                            break;
                    }
                }
                ss.WriteLine("			  </sources>");
                ss.WriteLine("			  <references basedir=\"${project::get-base-directory()}\">");
                ss.WriteLine("				  <lib>");
                ss.WriteLine("					  <include name=\"${project::get-base-directory()}\" />");
                //ss.WriteLine("					  <include name=\"${project::get-base-directory()}/${build.dir}\" />");
                ss.WriteLine("					  <include name=\"${build.dir}\" />");
                ss.WriteLine("				  </lib>");
                foreach (ReferenceNode refr in project.References)
                {
                    ss.WriteLine("				  <include name=\"{0}", Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReference(solution, refr)) + "\" />", '/'));
                }
                ss.WriteLine("			  </references>");

                ArrayList suppressWarningsArray = new ArrayList();
                ss.WriteLine("            <nowarn>");
                foreach (ConfigurationNode conf in project.Configurations)
                {
                    foreach (string s in conf.Options.SuppressWarnings.Split(new char[] { ',', ' ' }))
                    {
                        // duplicate check
                        if (!String.IsNullOrEmpty(s) && !suppressWarningsArray.Contains(s))
                        {
                            suppressWarningsArray.Add(s);
                            ss.WriteLine("                <warning number=\"{0}\" />", s);
                        }
                    }
                }
                suppressWarningsArray.Clear();

                ss.WriteLine("            </nowarn>");

                ss.WriteLine("		  </csc>");
                ss.WriteLine("	  </target>");

                ss.WriteLine("	  <target name=\"clean\">");
                ss.WriteLine("		  <delete dir=\"${bin.dir}\" failonerror=\"false\" />");
                ss.WriteLine("		  <delete dir=\"${obj.dir}\" failonerror=\"false\" />");
                ss.WriteLine("	  </target>");

                ss.WriteLine("	  <target name=\"doc\" description=\"Creates documentation.\">");
                if (hasDoc)
                {
                    ss.WriteLine("		  <property name=\"doc.target\" value=\"\" />");
                    ss.WriteLine("		  <if test=\"${platform::is-unix()}\">");
                    ss.WriteLine("			  <property name=\"doc.target\" value=\"Web\" />");
                    ss.WriteLine("		  </if>");
                    ss.WriteLine("		  <ndoc failonerror=\"false\" verbose=\"true\">");
                    ss.WriteLine("			  <assemblies basedir=\"${project::get-base-directory()}\">");
                    ss.Write("				  <include name=\"${build.dir}/${project::get-name()}");
                    if (project.Type == ProjectType.Library)
                    {
                        ss.WriteLine(".dll\" />");
                    }
                    else
                    {
                        ss.WriteLine(".exe\" />");
                    }

                    ss.WriteLine("			  </assemblies>");
                    ss.WriteLine("			  <summaries basedir=\"${project::get-base-directory()}\">");
                    ss.WriteLine("				  <include name=\"${build.dir}/${project::get-name()}.xml\"/>");
                    ss.WriteLine("			  </summaries>");
                    ss.WriteLine("			  <referencepaths basedir=\"${project::get-base-directory()}\">");
                    ss.WriteLine("				  <include name=\"${build.dir}\" />");
                    //					foreach(ReferenceNode refr in project.References)
                    //					{
                    //						string path = Helper.NormalizePath(Helper.MakePathRelativeTo(project.FullPath, BuildReferencePath(solution, refr)), '/');
                    //						if (path != "")
                    //						{
                    //							ss.WriteLine("				  <include name=\"{0}\" />", path);
                    //						}
                    //					}
                    ss.WriteLine("			  </referencepaths>");
                    ss.WriteLine("			  <documenters>");
                    ss.WriteLine("				  <documenter name=\"MSDN\">");
                    ss.WriteLine("					  <property name=\"OutputDirectory\" value=\"${build.dir}/doc/${project::get-name()}\" />");
                    ss.WriteLine("					  <property name=\"OutputTarget\" value=\"${doc.target}\" />");
                    ss.WriteLine("					  <property name=\"HtmlHelpName\" value=\"${project::get-name()}\" />");
                    ss.WriteLine("					  <property name=\"IncludeFavorites\" value=\"False\" />");
                    ss.WriteLine("					  <property name=\"Title\" value=\"${project::get-name()} SDK Documentation\" />");
                    ss.WriteLine("					  <property name=\"SplitTOCs\" value=\"False\" />");
                    ss.WriteLine("					  <property name=\"DefaulTOC\" value=\"\" />");
                    ss.WriteLine("					  <property name=\"ShowVisualBasic\" value=\"True\" />");
                    ss.WriteLine("					  <property name=\"AutoDocumentConstructors\" value=\"True\" />");
                    ss.WriteLine("					  <property name=\"ShowMissingSummaries\" value=\"${build.debug}\" />");
                    ss.WriteLine("					  <property name=\"ShowMissingRemarks\" value=\"${build.debug}\" />");
                    ss.WriteLine("					  <property name=\"ShowMissingParams\" value=\"${build.debug}\" />");
                    ss.WriteLine("					  <property name=\"ShowMissingReturns\" value=\"${build.debug}\" />");
                    ss.WriteLine("					  <property name=\"ShowMissingValues\" value=\"${build.debug}\" />");
                    ss.WriteLine("					  <property name=\"DocumentInternals\" value=\"False\" />");
                    ss.WriteLine("					  <property name=\"DocumentPrivates\" value=\"False\" />");
                    ss.WriteLine("					  <property name=\"DocumentProtected\" value=\"True\" />");
                    ss.WriteLine("					  <property name=\"DocumentEmptyNamespaces\" value=\"${build.debug}\" />");
                    ss.WriteLine("					  <property name=\"IncludeAssemblyVersion\" value=\"True\" />");
                    ss.WriteLine("				  </documenter>");
                    ss.WriteLine("			  </documenters>");
                    ss.WriteLine("		  </ndoc>");
                }
                ss.WriteLine("	  </target>");
                ss.WriteLine("</project>");
            }
            m_Kernel.CurrentWorkingDirectory.Pop();
        }
コード例 #32
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        public override void Parse(XmlNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            string path        = Helper.AttributeValue(node, "path", ".");
            string pattern     = Helper.AttributeValue(node, "pattern", "*");
            string destination = Helper.AttributeValue(node, "destination", string.Empty);
            bool   recurse     = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "recurse", "false"));
            bool   useRegex    = (bool)Helper.TranslateValue(typeof(bool), Helper.AttributeValue(node, "useRegex", "false"));
            string buildAction = Helper.AttributeValue(node, "buildAction", String.Empty);

            if (buildAction != string.Empty)
            {
                m_BuildAction = (BuildAction)Enum.Parse(typeof(BuildAction), buildAction);
            }


            //TODO: Figure out where the subtype node is being assigned
            //string subType = Helper.AttributeValue(node, "subType", string.Empty);
            //if (subType != String.Empty)
            //    m_SubType = (SubType)Enum.Parse(typeof(SubType), subType);
            m_ResourceName = Helper.AttributeValue(node, "resourceName", m_ResourceName);
            m_CopyToOutput = (CopyToOutput)Enum.Parse(typeof(CopyToOutput), Helper.AttributeValue(node, "copyToOutput", m_CopyToOutput.ToString()));
            m_Link         = bool.Parse(Helper.AttributeValue(node, "link", bool.FalseString));
            if (m_Link)
            {
                m_LinkPath = Helper.AttributeValue(node, "linkPath", string.Empty);
            }
            m_PreservePath = bool.Parse(Helper.AttributeValue(node, "preservePath", bool.FalseString));

            if (buildAction == "Copy")
            {
                m_Destination = destination;
            }

            if (path != null && path.Length == 0)
            {
                path = ".";//use current directory
            }
            //throw new WarningException("Match must have a 'path' attribute");

            if (pattern == null)
            {
                throw new WarningException("Match must have a 'pattern' attribute");
            }

            path = Helper.NormalizePath(path);
            if (!Directory.Exists(path))
            {
                throw new WarningException("Match path does not exist: {0}", path);
            }

            try
            {
                if (useRegex)
                {
                    m_Regex = new Regex(pattern);
                }
            }
            catch (ArgumentException ex)
            {
                throw new WarningException("Could not compile regex pattern: {0}", ex.Message);
            }


            foreach (XmlNode child in node.ChildNodes)
            {
                IDataNode dataNode = Kernel.Instance.ParseNode(child, this);
                if (dataNode is ExcludeNode)
                {
                    ExcludeNode excludeNode = (ExcludeNode)dataNode;
                    m_Exclusions.Add(excludeNode);
                }
            }

            RecurseDirectories(path, pattern, recurse, useRegex, m_Exclusions);

            if (m_Files.Count < 1)
            {
                // Include the project name when the match node returns no matches to provide extra
                // debug info.
                ProjectNode project     = Parent.Parent as ProjectNode;
                string      projectName = "";

                if (project != null)
                {
                    projectName = " in project " + project.AssemblyName;
                }

                throw new WarningException("Match" + projectName + " returned no files: {0}{1}", Helper.EndPath(path), pattern);
            }
            m_Regex = null;
        }