本文整理汇总了C#中Prebuild.Core.Nodes.SolutionNode类的典型用法代码示例。如果您正苦于以下问题:C# SolutionNode类的具体用法?C# SolutionNode怎么用?C# SolutionNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SolutionNode类属于Prebuild.Core.Nodes命名空间,在下文中一共展示了SolutionNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildReference
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: BuildReference
private static string BuildReference(SolutionNode solution, ReferenceNode refr)
{
string ret = "<ProjectReference type=\"";
if(solution.ProjectsTable.ContainsKey(refr.Name))
{
ret += "Project\"";
ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />";
}
else
{
ProjectNode project = (ProjectNode)refr.Parent;
string fileRef = FindFileReference(refr.Name, project);
if(refr.Path != null || fileRef != null)
{
ret += "Assembly\" refto=\"";
string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
ret += finalPath;
ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
return ret;
}
ret += "Gac\"";
ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\"";
ret += " refto=\"";
try
{
/*
Day changed to 28 Mar 2007
...
08:09 < cj> is there anything that replaces Assembly.LoadFromPartialName() ?
08:09 < jonp> no
08:10 < jonp> in their infinite wisdom [sic], microsoft decided that the
ability to load any assembly version by-name was an inherently
bad idea
08:11 < cj> I'm thinking of a bunch of four-letter words right now...
08:11 < cj> security through making it difficult for the developer!!!
08:12 < jonp> just use the Obsolete API
08:12 < jonp> it should still work
08:12 < cj> alrighty.
08:12 < jonp> you just get warnings when using it
*/
Assembly assem = Assembly.LoadWithPartialName(refr.Name);
ret += assem.FullName;
//ret += refr.Name;
}
catch (System.NullReferenceException e)
{
e.ToString();
ret += refr.Name;
}
ret += "\" />";
}
return ret;
}
示例3: BuildReference
private static string BuildReference(SolutionNode solution, ReferenceNode refr)
{
string ret = "";
if (solution.ProjectsTable.ContainsKey(refr.Name))
{
ProjectNode project = (ProjectNode)solution.ProjectsTable[refr.Name];
string fileRef = FindFileReference(refr.Name, project);
string finalPath = Helper.NormalizePath(Helper.MakeFilePath(project.FullPath + "/${build.dir}/", refr.Name, "dll"), '/');
ret += finalPath;
return ret;
}
else
{
ProjectNode project = (ProjectNode)refr.Parent;
string fileRef = FindFileReference(refr.Name, project);
if (refr.Path != null || fileRef != null)
{
string finalPath = (refr.Path != null) ? Helper.NormalizePath(refr.Path + "/" + refr.Name + ".dll", '/') : fileRef;
ret += finalPath;
return ret;
}
try
{
//Assembly assem = Assembly.Load(refr.Name);
//if (assem != null)
//{
//ret += (refr.Name + ".dll");
//}
//else
//{
ret += (refr.Name + ".dll");
//}
}
catch (System.NullReferenceException e)
{
e.ToString();
ret += refr.Name + ".dll";
}
}
return ret;
}
示例4: BuildReference
private static string BuildReference(SolutionNode solution, ReferenceNode refr)
{
string ret = "<ProjectReference type=\"";
if(solution.ProjectsTable.ContainsKey(refr.Name))
{
ret += "Project\"";
ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\" refto=\"" + refr.Name + "\" />";
}
else
{
ProjectNode project = (ProjectNode)refr.Parent;
string fileRef = FindFileReference(refr.Name, project);
if(refr.Path != null || fileRef != null)
{
ret += "Assembly\" refto=\"";
string finalPath = (refr.Path != null) ? Helper.MakeFilePath(refr.Path, refr.Name, "dll") : fileRef;
ret += finalPath;
ret += "\" localcopy=\"" + refr.LocalCopy.ToString() + "\" />";
return ret;
}
ret += "Gac\"";
ret += " localcopy=\"" + refr.LocalCopy.ToString() + "\"";
ret += " refto=\"";
try
{
Assembly assem = Assembly.LoadWithPartialName(refr.Name);
ret += assem.FullName;
}
catch (System.NullReferenceException e)
{
e.ToString();
ret += refr.Name;
}
ret += "\" />";
}
return ret;
}
示例5: WriteProjectFiles
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: WriteProject
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=\"\"");
//.........这里部分代码省略.........
示例7: CleanSolution
private void CleanSolution(SolutionNode solution)
{
m_Kernel.Log.Write("Cleaning Autotools make files for", solution.Name);
string slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "am");
Helper.DeleteIfExists(slnFile);
slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile", "in");
Helper.DeleteIfExists(slnFile);
slnFile = Helper.MakeFilePath(solution.FullPath, "configure", "ac");
Helper.DeleteIfExists(slnFile);
slnFile = Helper.MakeFilePath(solution.FullPath, "configure");
Helper.DeleteIfExists(slnFile);
slnFile = Helper.MakeFilePath(solution.FullPath, "Makefile");
Helper.DeleteIfExists(slnFile);
foreach (ProjectNode project in solution.Projects)
{
CleanProject(project);
}
m_Kernel.Log.Write("");
}
示例8: WriteProject
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))
//.........这里部分代码省略.........
示例9: WriteCombine
private void WriteCombine(SolutionNode solution)
{
#region "Create Solution directory if it doesn't exist"
string solutionDir = Path.Combine(solution.FullPath,
Path.Combine("autotools",
solution.Name));
chkMkDir(solutionDir);
#endregion
#region "Write Solution-level files"
XsltArgumentList argList = new XsltArgumentList();
argList.AddParam("solutionName", "", solution.Name);
// $solutionDir is $rootDir/$solutionName/
transformToFile(Path.Combine(solutionDir, "configure.ac"),
argList, "/Autotools/SolutionConfigureAc");
transformToFile(Path.Combine(solutionDir, "Makefile.am"),
argList, "/Autotools/SolutionMakefileAm");
transformToFile(Path.Combine(solutionDir, "autogen.sh"),
argList, "/Autotools/SolutionAutogenSh");
#endregion
foreach (ProjectNode project in solution.ProjectsTableOrder)
{
m_Kernel.Log.Write(String.Format("Writing project: {0}",
project.Name));
WriteProject(solution, project);
}
}
示例10: CleanSolution
private void CleanSolution(SolutionNode solution)
{
m_Kernel.Log.Write("Cleaning SharpDevelop combine and project files for", solution.Name);
string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "cmbx");
Helper.DeleteIfExists(slnFile);
foreach(ProjectNode project in solution.Projects)
{
CleanProject(project);
}
m_Kernel.Log.Write("");
}
示例11: WriteSolution
private void WriteSolution(SolutionNode solution)
{
kernel.Log.Write("Creating {0} solution and project files", this.VersionName);
foreach (ProjectNode project in solution.Projects)
{
kernel.Log.Write("...Creating project: {0}", project.Name);
WriteProject(solution, project);
}
kernel.Log.Write("");
string solutionFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
StreamWriter ss = new StreamWriter(solutionFile);
kernel.CurrentWorkingDirectory.Push();
Helper.SetCurrentDir(Path.GetDirectoryName(solutionFile));
using (ss)
{
ss.WriteLine("Microsoft Visual Studio Solution File, Format Version {0}", this.SolutionVersion);
ss.WriteLine("# Visual Studio 2005");
foreach (ProjectNode project in solution.Projects)
{
if (!tools.ContainsKey(project.Language))
{
throw new UnknownLanguageException("Unknown .NET language: " + project.Language);
}
ToolInfo toolInfo = (ToolInfo)tools[project.Language];
string path = Helper.MakePathRelativeTo(solution.FullPath, project.FullPath);
ss.WriteLine("Project(\"{0}\") = \"{1}\", \"{2}\", \"{{{3}}}\"",
toolInfo.Guid, project.Name, Helper.MakeFilePath(path, project.Name,
toolInfo.FileExtension), project.Guid.ToString().ToUpper());
//ss.WriteLine(" ProjectSection(ProjectDependencies) = postProject");
//ss.WriteLine(" EndProjectSection");
ss.WriteLine("EndProject");
}
if (solution.Files != null)
{
ss.WriteLine("Project(\"{0}\") = \"Solution Items\", \"Solution Items\", \"{1}\"", "{2150E333-8FDC-42A3-9474-1A3956D46DE8}", "{468F1D07-AD17-4CC3-ABD0-2CA268E4E1A6}");
ss.WriteLine("\tProjectSection(SolutionItems) = preProject");
foreach (string file in solution.Files)
ss.WriteLine("\t\t{0} = {0}", file);
ss.WriteLine("\tEndProjectSection");
ss.WriteLine("EndProject");
}
ss.WriteLine("Global");
ss.WriteLine(" GlobalSection(SolutionConfigurationPlatforms) = preSolution");
foreach (ConfigurationNode conf in solution.Configurations)
{
ss.WriteLine(" {0}|Any CPU = {0}|Any CPU", conf.Name);
}
ss.WriteLine(" EndGlobalSection");
if (solution.Projects.Count > 1)
{
ss.WriteLine(" GlobalSection(ProjectDependencies) = postSolution");
}
foreach (ProjectNode project in solution.Projects)
{
for (int i = 0; i < project.References.Count; i++)
{
ReferenceNode refr = (ReferenceNode)project.References[i];
if (solution.ProjectsTable.ContainsKey(refr.Name))
{
ProjectNode refProject = (ProjectNode)solution.ProjectsTable[refr.Name];
ss.WriteLine(" ({{{0}}}).{1} = ({{{2}}})",
project.Guid.ToString().ToUpper()
, i,
refProject.Guid.ToString().ToUpper()
);
}
}
}
if (solution.Projects.Count > 1)
{
ss.WriteLine(" EndGlobalSection");
}
ss.WriteLine(" GlobalSection(ProjectConfigurationPlatforms) = postSolution");
foreach (ProjectNode project in solution.Projects)
{
foreach (ConfigurationNode conf in solution.Configurations)
{
ss.WriteLine(" {{{0}}}.{1}|Any CPU.ActiveCfg = {1}|Any CPU",
project.Guid.ToString().ToUpper(),
conf.Name);
ss.WriteLine(" {{{0}}}.{1}|Any CPU.Build.0 = {1}|Any CPU",
project.Guid.ToString().ToUpper(),
conf.Name);
}
}
ss.WriteLine(" EndGlobalSection");
ss.WriteLine(" GlobalSection(SolutionProperties) = preSolution");
//.........这里部分代码省略.........
示例12: CleanSolution
private void CleanSolution(SolutionNode solution)
{
kernel.Log.Write("Cleaning {0} solution and project files", this.VersionName, solution.Name);
string slnFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "sln");
string suoFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "suo");
Helper.DeleteIfExists(slnFile);
Helper.DeleteIfExists(suoFile);
foreach (ProjectNode project in solution.Projects)
{
CleanProject(project);
}
kernel.Log.Write("");
}
示例13: CleanSolution
private void CleanSolution(SolutionNode solution)
{
m_Kernel.Log.Write("Cleaning makefile for {0}", solution.Name);
string file = Helper.MakeFilePath(solution.FullPath, solution.Name, "make");
Helper.DeleteIfExists(file);
m_Kernel.Log.Write("");
}
示例14: WriteCombine
private void WriteCombine(SolutionNode solution)
{
m_Kernel.Log.Write("Creating NAnt build files");
foreach (ProjectNode project in solution.Projects)
{
if (m_Kernel.AllowProject(project.FilterGroups))
{
m_Kernel.Log.Write("...Creating project: {0}", project.Name);
WriteProject(solution, project);
}
}
m_Kernel.Log.Write("");
string combFile = Helper.MakeFilePath(solution.FullPath, solution.Name, "build");
StreamWriter ss = new StreamWriter(combFile);
m_Kernel.CurrentWorkingDirectory.Push();
Helper.SetCurrentDir(Path.GetDirectoryName(combFile));
using (ss)
{
ss.WriteLine("<?xml version=\"1.0\" ?>");
ss.WriteLine("<project name=\"{0}\" default=\"build\">", solution.Name);
ss.WriteLine(" <echo message=\"Using '${nant.settings.currentframework}' Framework\"/>");
ss.WriteLine();
//ss.WriteLine(" <property name=\"dist.dir\" value=\"dist\" />");
//ss.WriteLine(" <property name=\"source.dir\" value=\"source\" />");
ss.WriteLine(" <property name=\"bin.dir\" value=\"bin\" />");
ss.WriteLine(" <property name=\"obj.dir\" value=\"obj\" />");
ss.WriteLine(" <property name=\"doc.dir\" value=\"doc\" />");
ss.WriteLine(" <property name=\"project.main.dir\" value=\"${project::get-base-directory()}\" />");
// Use the active configuration, which is the first configuration name in the prebuild file.
Dictionary<string,string> emittedConfigurations = new Dictionary<string, string>();
ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", solution.ActiveConfig);
ss.WriteLine();
foreach (ConfigurationNode conf in solution.Configurations)
{
// If the name isn't in the emitted configurations, we give a high level target to the
// platform specific on. This lets "Debug" point to "Debug-AnyCPU".
if (!emittedConfigurations.ContainsKey(conf.Name))
{
// Add it to the dictionary so we only emit one.
emittedConfigurations.Add(conf.Name, conf.Platform);
// Write out the target block.
ss.WriteLine(" <target name=\"{0}\" description=\"{0}|{1}\" depends=\"{0}-{1}\">", conf.Name, conf.Platform);
ss.WriteLine(" </target>");
ss.WriteLine();
}
// Write out the target for the configuration.
ss.WriteLine(" <target name=\"{0}-{1}\" description=\"{0}|{1}\">", conf.Name, conf.Platform);
ss.WriteLine(" <property name=\"project.config\" value=\"{0}\" />", conf.Name);
ss.WriteLine(" <property name=\"build.debug\" value=\"{0}\" />", conf.Options["DebugInformation"].ToString().ToLower());
ss.WriteLine("\t\t <property name=\"build.platform\" value=\"{0}\" />", conf.Platform);
ss.WriteLine(" </target>");
ss.WriteLine();
}
ss.WriteLine(" <target name=\"net-1.1\" description=\"Sets framework to .NET 1.1\">");
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-1.1\" />");
ss.WriteLine(" </target>");
ss.WriteLine();
ss.WriteLine(" <target name=\"net-2.0\" description=\"Sets framework to .NET 2.0\">");
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-2.0\" />");
ss.WriteLine(" </target>");
ss.WriteLine();
ss.WriteLine(" <target name=\"net-3.5\" description=\"Sets framework to .NET 3.5\">");
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"net-3.5\" />");
ss.WriteLine(" </target>");
ss.WriteLine();
ss.WriteLine(" <target name=\"mono-1.0\" description=\"Sets framework to mono 1.0\">");
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-1.0\" />");
ss.WriteLine(" </target>");
ss.WriteLine();
ss.WriteLine(" <target name=\"mono-2.0\" description=\"Sets framework to mono 2.0\">");
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-2.0\" />");
ss.WriteLine(" </target>");
ss.WriteLine();
ss.WriteLine(" <target name=\"mono-3.5\" description=\"Sets framework to mono 3.5\">");
ss.WriteLine(" <property name=\"nant.settings.currentframework\" value=\"mono-3.5\" />");
ss.WriteLine(" </target>");
ss.WriteLine();
ss.WriteLine(" <target name=\"init\" description=\"\">");
ss.WriteLine(" <call target=\"${project.config}\" />");
ss.WriteLine(" <property name=\"sys.os.platform\"");
ss.WriteLine(" value=\"${platform::get-name()}\"");
ss.WriteLine(" />");
ss.WriteLine(" <echo message=\"Platform ${sys.os.platform}\" />");
ss.WriteLine(" <property name=\"build.dir\" value=\"${bin.dir}/${project.config}\" />");
//.........这里部分代码省略.........
示例15: WriteProject
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")
//{
//.........这里部分代码省略.........