void AddProjectReference(StringBuilder refs, VsCsproj result, VsCsproj lastMatching, string r) { refs.AppendFormat(" <ProjectReference Include=\"{0}\">{1}", GetRelativePath(result.csprojFileName, lastMatching.csprojFileName), NewLine); refs.Append(" <Project>" + lastMatching.projectGuid + "</Project>" + NewLine); refs.Append(" <Name>" + Path.GetFileNameWithoutExtension(lastMatching.csprojFileName) + "</Name>" + NewLine); refs.Append(" </ProjectReference>" + NewLine); if (!result.projReferences.Contains(lastMatching)) { result.projReferences.Add(lastMatching); } }
void AddProjectReference(StringBuilder refs, VsCsproj result, MsbuildGenerator match, string r, string alias) { refs.AppendFormat(" <ProjectReference Include=\"{0}\">{1}", GetRelativePath(result.csProjFilename, match.CsprojFilename), NewLine); refs.Append(" <Project>" + match.projectGuid + "</Project>" + NewLine); refs.Append(" <Name>" + Path.GetFileNameWithoutExtension(match.CsprojFilename) + "</Name>" + NewLine); if (alias != null) { refs.Append(" <Aliases>" + alias + "</Aliases>"); } refs.Append(" </ProjectReference>" + NewLine); if (!result.projReferences.Contains(match.Csproj)) { result.projReferences.Add(match.Csproj); } }
public MsbuildGenerator(XElement xproject) { this.xproject = xproject; dir = xproject.Attribute("dir").Value; library = xproject.Attribute("library").Value; CsprojFilename = "..\\..\\mcs\\" + dir + "\\" + library + ".csproj"; LibraryOutput = xproject.Element("library_output").Value; projectGuid = LookupOrGenerateGuid(); fx_version = xproject.Element("fx_version").Value; Csproj = new VsCsproj() { csProjFilename = this.CsprojFilename, projectGuid = this.projectGuid, library_output = this.LibraryOutput, fx_version = double.Parse(fx_version), library = this.library, MsbuildGenerator = this }; if (dir == "mcs") { mcs_topdir = "../"; class_dir = "../class/"; base_dir = "../../mcs/mcs"; } else { mcs_topdir = "../"; foreach (char c in dir) { if (c == '/') { mcs_topdir = "..//" + mcs_topdir; } } class_dir = mcs_topdir.Substring(3); base_dir = Path.Combine("..", "..", "mcs", dir); } AbsoluteLibraryOutput = Path.GetFullPath(Path.Combine(base_dir, LibraryOutput)); }
public VsCsproj Generate(XElement xproject, List <MsbuildGenerator.VsCsproj> projects, bool showWarnings = false) { var result = new VsCsproj(); string library = xproject.Attribute("library").Value; string boot, flags, output_name, built_sources, library_output, response, fx_version, profile; boot = xproject.Element("boot").Value; flags = xproject.Element("flags").Value; output_name = xproject.Element("output").Value; built_sources = xproject.Element("built_sources").Value; library_output = xproject.Element("library_output").Value; response = xproject.Element("response").Value; fx_version = xproject.Element("fx_version").Value; //if (library.EndsWith("-build")) fx_version = "2.0"; // otherwise problem if .NET4.5 is installed, seems. (https://github.com/nikhilk/scriptsharp/issues/156) profile = xproject.Element("profile").Value; if (string.IsNullOrEmpty(response)) { // Address the issue where entries are missing the fx_version // Should be fixed in the Makefile or elsewhere; this is a workaround //<fx_version>basic</fx_version> //<profile>./../build/deps/mcs.exe.sources.response</profile> //<response></response> response = profile; profile = fx_version; if (response.Contains("build") || response.Contains("basic") || response.Contains(profile_2_0)) { fx_version = "2.0"; if (response.Contains(profile_2_0)) { profile = "net_2_0"; } } if (response.Contains("build") || response.Contains("basic") || response.Contains(profile_2_0)) { fx_version = "2.0"; } else if (response.Contains(profile_3_5)) { fx_version = "3.5"; profile = "net_3_5"; } else if (response.Contains(profile_4_0)) { fx_version = "4.0"; profile = "net_4_0"; } else if (response.Contains(profile_4_5)) { fx_version = "4.5"; profile = "net_4_5"; } } // // Prebuild code, might be in inputs, check: // inputs/LIBRARY-PROFILE.pre // inputs/LIBRARY.pre // string prebuild = Load(library + ".pre"); string prebuild_windows, prebuild_unix; int q = library.IndexOf("-"); if (q != -1) { prebuild = prebuild + Load(library.Substring(0, q) + ".pre"); } if (prebuild.IndexOf("@MONO@") != -1) { prebuild_unix = prebuild.Replace("@MONO@", "mono").Replace("@CAT@", "cat"); prebuild_windows = prebuild.Replace("@MONO@", "").Replace("@CAT@", "type"); } else { prebuild_unix = prebuild; prebuild_windows = prebuild; } const string condition_unix = "Condition=\" '$(OS)' != 'Windows_NT' \""; const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \""; prebuild = " <PreBuildEvent " + condition_unix + ">\n" + prebuild_unix + "\n </PreBuildEvent>\n" + " <PreBuildEvent " + condition_windows + ">\n" + prebuild_windows + "\n </PreBuildEvent>\n"; var all_args = new Queue <string []> (); all_args.Enqueue(flags.Split()); while (all_args.Count > 0) { string [] f = all_args.Dequeue(); for (int i = 0; i < f.Length; i++) { if (f [i] [0] == '-') { f [i] = "/" + f [i].Substring(1); } if (f [i] [0] == '@') { string [] extra_args; string response_file = f [i].Substring(1); var resp_file_full = Path.Combine(base_dir, response_file); extra_args = LoadArgs(resp_file_full); if (extra_args == null) { Console.WriteLine("Unable to open response file: " + resp_file_full); Environment.Exit(1); } all_args.Enqueue(extra_args); continue; } if (CSCParseOption(f [i], ref f)) { continue; } Console.WriteLine("Failure with {0}", f [i]); Environment.Exit(1); } } string [] source_files; //Console.WriteLine ("Base: {0} res: {1}", base_dir, response); using (var reader = new StreamReader(NativeName(base_dir + "\\" + response))) { source_files = reader.ReadToEnd().Split(); } Array.Sort(source_files); StringBuilder sources = new StringBuilder(); foreach (string s in source_files) { if (s.Length == 0) { continue; } string src = s.Replace("/", "\\"); if (src.StartsWith(@"Test\..\")) { src = src.Substring(8, src.Length - 8); } sources.AppendFormat(" <Compile Include=\"{0}\" />" + NewLine, src); } source_files = built_sources.Split(); Array.Sort(source_files); foreach (string s in source_files) { if (s.Length == 0) { continue; } string src = s.Replace("/", "\\"); if (src.StartsWith(@"Test\..\")) { src = src.Substring(8, src.Length - 8); } sources.AppendFormat(" <Compile Include=\"{0}\" />" + NewLine, src); } sources.Remove(sources.Length - 1, 1); //if (library == "corlib-build") // otherwise, does not compile on fx_version == 4.0 //{ // references.Add("System.dll"); // references.Add("System.Xml.dll"); //} //if (library == "System.Core-build") // otherwise, slow compile. May be a transient need. //{ // this.ignore_warning.Add(1685); // this.ignore_warning.Add(0436); //} result.library = library; result.csprojFileName = "..\\..\\mcs\\" + dir + "\\" + library + ".csproj"; var refs = new StringBuilder(); bool is_test = response.Contains("_test_"); if (is_test) { // F:\src\mono\mcs\class\lib\net_2_0\nunit.framework.dll // F:\src\mono\mcs\class\SomeProject\SomeProject_test_-net_2_0.csproj var nunitLibPath = string.Format(@"..\lib\{0}\nunit.framework.dll", profile); refs.Append(string.Format(" <Reference Include=\"{0}\" />" + NewLine, nunitLibPath)); } var resources = new StringBuilder(); if (embedded_resources.Count > 0) { resources.AppendFormat(" <ItemGroup>" + NewLine); foreach (var dk in embedded_resources) { resources.AppendFormat(" <EmbeddedResource Include=\"{0}\">" + NewLine, dk.Key); resources.AppendFormat(" <LogicalName>{0}</LogicalName>" + NewLine, dk.Value); resources.AppendFormat(" </EmbeddedResource>" + NewLine); } resources.AppendFormat(" </ItemGroup>" + NewLine); } if (references.Count > 0 || reference_aliases.Count > 0) { // -r:mscorlib.dll -r:System.dll //<ProjectReference Include="..\corlib\corlib-basic.csproj"> // <Project>{155aef28-c81f-405d-9072-9d52780e3e70}</Project> // <Name>corlib-basic</Name> //</ProjectReference> //<ProjectReference Include="..\System\System-basic.csproj"> // <Project>{2094e859-db2f-481f-9630-f89d31d9ed48}</Project> // <Name>System-basic</Name> //</ProjectReference> var refdistinct = references.Distinct(); foreach (string r in refdistinct) { VsCsproj lastMatching = GetMatchingCsproj(Path.GetFileName(r), projects); if (lastMatching != null) { AddProjectReference(refs, result, lastMatching, r, null); } else { if (showWarnings) { Console.WriteLine("{0}: Could not find a matching project reference for {1}", library, Path.GetFileName(r)); Console.WriteLine(" --> Adding reference with hintpath instead"); } refs.Append(" <Reference Include=\"" + r + "\">" + NewLine); refs.Append(" <SpecificVersion>False</SpecificVersion>" + NewLine); refs.Append(" <HintPath>" + r + "</HintPath>" + NewLine); refs.Append(" <Private>False</Private>" + NewLine); refs.Append(" </Reference>" + NewLine); } } foreach (string r in reference_aliases) { int index = r.IndexOf('='); string alias = r.Substring(0, index); string assembly = r.Substring(index + 1); VsCsproj lastMatching = GetMatchingCsproj(Path.GetFileName(assembly), projects); if (lastMatching != null) { AddProjectReference(refs, result, lastMatching, r, alias); } else { throw new NotSupportedException(string.Format("From {0}, could not find a matching project reference for {1}", library, r)); refs.Append(" <Reference Include=\"" + assembly + "\">" + NewLine); refs.Append(" <SpecificVersion>False</SpecificVersion>" + NewLine); refs.Append(" <HintPath>" + r + "</HintPath>" + NewLine); refs.Append(" <Aliases>" + alias + "</Aliases>" + NewLine); refs.Append(" </Reference>" + NewLine); } } } // Possible inputs: // ../class/lib/build/tmp/System.Xml.dll [No longer possible, we should be removing this from order.xml] // /class/lib/basic/System.Core.dll // <library_output>mcs.exe</library_output> string build_output_dir; if (library_output.Contains("/")) { build_output_dir = Path.GetDirectoryName(library_output); } else { build_output_dir = "bin\\Debug\\" + library; } string postbuild_unix = string.Empty; string postbuild_windows = string.Empty; var postbuild = " <PostBuildEvent " + condition_unix + ">\n" + postbuild_unix + "\n </PostBuildEvent>\n" + " <PostBuildEvent " + condition_windows + ">\n" + postbuild_windows + "\n </PostBuildEvent>"; bool basic_or_build = (library.Contains("-basic") || library.Contains("-build")); // // Replace the template values // result.projectGuid = "{" + Guid.NewGuid().ToString().ToUpper() + "}"; result.library_output = library_output; result.fx_version = double.Parse(fx_version); result.output = template. Replace("@PROJECTGUID@", result.projectGuid). Replace("@DEFINES@", defines.ToString()). Replace("@DISABLEDWARNINGS@", string.Join(",", (from i in ignore_warning select i.ToString()).ToArray())). //Replace("@NOSTDLIB@", (basic_or_build || (!StdLib)) ? "<NoStdLib>true</NoStdLib>" : string.Empty). Replace("@NOSTDLIB@", "<NoStdLib>" + (!StdLib).ToString() + "</NoStdLib>"). Replace("@NOCONFIG@", "<NoConfig>" + (!load_default_config).ToString() + "</NoConfig>"). Replace("@ALLOWUNSAFE@", Unsafe ? "<AllowUnsafeBlocks>true</AllowUnsafeBlocks>" : ""). Replace("@FX_VERSION", fx_version). Replace("@ASSEMBLYNAME@", Path.GetFileNameWithoutExtension(output_name)). Replace("@OUTPUTDIR@", build_output_dir). Replace("@DEFINECONSTANTS@", defines.ToString()). Replace("@DEBUG@", want_debugging_support ? "true" : "false"). Replace("@DEBUGTYPE@", want_debugging_support ? "full" : "pdbonly"). Replace("@REFERENCES@", refs.ToString()). Replace("@PREBUILD@", prebuild). Replace("@POSTBUILD@", postbuild). //Replace ("@ADDITIONALLIBPATHS@", String.Format ("<AdditionalLibPaths>{0}</AdditionalLibPaths>", string.Join (",", libs.ToArray ()))). Replace("@ADDITIONALLIBPATHS@", String.Empty). Replace("@RESOURCES@", resources.ToString()). Replace("@OPTIMIZE@", Optimize ? "true" : "false"). Replace("@SOURCES@", sources.ToString()); //Console.WriteLine ("Generated {0}", ofile.Replace ("\\", "/")); var generatedProjFile = NativeName(result.csprojFileName); Console.WriteLine("Generating: {0}", generatedProjFile); using (var o = new StreamWriter(generatedProjFile)) { o.WriteLine(result.output); } return(result); }
void AddProjectReference (StringBuilder refs, VsCsproj result, VsCsproj lastMatching, string r, string alias) { refs.AppendFormat (" <ProjectReference Include=\"{0}\">{1}", GetRelativePath (result.csprojFileName, lastMatching.csprojFileName), NewLine); refs.Append (" <Project>" + lastMatching.projectGuid + "</Project>" + NewLine); refs.Append (" <Name>" + Path.GetFileNameWithoutExtension (lastMatching.csprojFileName) + "</Name>" + NewLine); if (alias != null) refs.Append (" <Aliases>" + alias + "</Aliases>"); refs.Append (" </ProjectReference>" + NewLine); if (!result.projReferences.Contains (lastMatching)) result.projReferences.Add (lastMatching); }
public VsCsproj Generate (XElement xproject, List<MsbuildGenerator.VsCsproj> projects, bool showWarnings = false) { var result = new VsCsproj (); string library = xproject.Attribute ("library").Value; string boot, flags, output_name, built_sources, library_output, response, fx_version, profile; boot = xproject.Element ("boot").Value; flags = xproject.Element ("flags").Value; output_name = xproject.Element ("output").Value; built_sources = xproject.Element ("built_sources").Value; library_output = xproject.Element ("library_output").Value; response = xproject.Element ("response").Value; fx_version = xproject.Element ("fx_version").Value; //if (library.EndsWith("-build")) fx_version = "2.0"; // otherwise problem if .NET4.5 is installed, seems. (https://github.com/nikhilk/scriptsharp/issues/156) profile = xproject.Element ("profile").Value; if (string.IsNullOrEmpty (response)) { // Address the issue where entries are missing the fx_version // Should be fixed in the Makefile or elsewhere; this is a workaround //<fx_version>basic</fx_version> //<profile>./../build/deps/mcs.exe.sources.response</profile> //<response></response> response = profile; profile = fx_version; if (response.Contains ("build") || response.Contains ("basic") || response.Contains (profile_2_0)) { fx_version = "2.0"; if (response.Contains (profile_2_0)) profile = "net_2_0"; } if (response.Contains ("build") || response.Contains ("basic") || response.Contains (profile_2_0)) { fx_version = "2.0"; } else if (response.Contains (profile_3_5)) { fx_version = "3.5"; profile = "net_3_5"; } else if (response.Contains (profile_4_0)) { fx_version = "4.0"; profile = "net_4_0"; } else if (response.Contains (profile_4_5)) { fx_version = "4.5"; profile = "net_4_5"; } } // // Prebuild code, might be in inputs, check: // inputs/LIBRARY-PROFILE.pre // inputs/LIBRARY.pre // string prebuild = Load (library + ".pre"); string prebuild_windows, prebuild_unix; int q = library.IndexOf ("-"); if (q != -1) prebuild = prebuild + Load (library.Substring (0, q) + ".pre"); if (prebuild.IndexOf ("@MONO@") != -1){ prebuild_unix = prebuild.Replace ("@MONO@", "mono").Replace ("@CAT@", "cat"); prebuild_windows = prebuild.Replace ("@MONO@", "").Replace ("@CAT@", "type"); } else { prebuild_unix = prebuild; prebuild_windows = prebuild; } const string condition_unix = "Condition=\" '$(OS)' != 'Windows_NT' \""; const string condition_windows = "Condition=\" '$(OS)' == 'Windows_NT' \""; prebuild = " <PreBuildEvent " + condition_unix + ">\n" + prebuild_unix + "\n </PreBuildEvent>\n" + " <PreBuildEvent " + condition_windows + ">\n" + prebuild_windows + "\n </PreBuildEvent>\n"; var all_args = new Queue<string []> (); all_args.Enqueue (flags.Split ()); while (all_args.Count > 0) { string [] f = all_args.Dequeue (); for (int i = 0; i < f.Length; i++) { if (f [i] [0] == '-') f [i] = "/" + f [i].Substring (1); if (f [i] [0] == '@') { string [] extra_args; string response_file = f [i].Substring (1); var resp_file_full = Path.Combine (base_dir, response_file); extra_args = LoadArgs (resp_file_full); if (extra_args == null) { Console.WriteLine ("Unable to open response file: " + resp_file_full); Environment.Exit (1); } all_args.Enqueue (extra_args); continue; } if (CSCParseOption (f [i], ref f)) continue; Console.WriteLine ("Failure with {0}", f [i]); Environment.Exit (1); } } string [] source_files; //Console.WriteLine ("Base: {0} res: {1}", base_dir, response); using (var reader = new StreamReader (NativeName (base_dir + "\\" + response))) { source_files = reader.ReadToEnd ().Split (); } Array.Sort (source_files); StringBuilder sources = new StringBuilder (); foreach (string s in source_files) { if (s.Length == 0) continue; string src = s.Replace ("/", "\\"); if (src.StartsWith (@"Test\..\")) src = src.Substring (8, src.Length - 8); sources.AppendFormat (" <Compile Include=\"{0}\" />" + NewLine, src); } source_files = built_sources.Split (); Array.Sort (source_files); foreach (string s in source_files) { if (s.Length == 0) continue; string src = s.Replace ("/", "\\"); if (src.StartsWith (@"Test\..\")) src = src.Substring (8, src.Length - 8); sources.AppendFormat (" <Compile Include=\"{0}\" />" + NewLine, src); } sources.Remove (sources.Length - 1, 1); //if (library == "corlib-build") // otherwise, does not compile on fx_version == 4.0 //{ // references.Add("System.dll"); // references.Add("System.Xml.dll"); //} //if (library == "System.Core-build") // otherwise, slow compile. May be a transient need. //{ // this.ignore_warning.Add(1685); // this.ignore_warning.Add(0436); //} result.library = library; result.csprojFileName = "..\\..\\mcs\\" + dir + "\\" + library + ".csproj"; var refs = new StringBuilder (); bool is_test = response.Contains ("_test_"); if (is_test) { // F:\src\mono\mcs\class\lib\net_2_0\nunit.framework.dll // F:\src\mono\mcs\class\SomeProject\SomeProject_test_-net_2_0.csproj var nunitLibPath = string.Format (@"..\lib\{0}\nunit.framework.dll", profile); refs.Append (string.Format (" <Reference Include=\"{0}\" />" + NewLine, nunitLibPath)); } var resources = new StringBuilder (); if (embedded_resources.Count > 0) { resources.AppendFormat (" <ItemGroup>" + NewLine); foreach (var dk in embedded_resources) { resources.AppendFormat (" <EmbeddedResource Include=\"{0}\">" + NewLine, dk.Key); resources.AppendFormat (" <LogicalName>{0}</LogicalName>" + NewLine, dk.Value); resources.AppendFormat (" </EmbeddedResource>" + NewLine); } resources.AppendFormat (" </ItemGroup>" + NewLine); } if (references.Count > 0 || reference_aliases.Count > 0) { // -r:mscorlib.dll -r:System.dll //<ProjectReference Include="..\corlib\corlib-basic.csproj"> // <Project>{155aef28-c81f-405d-9072-9d52780e3e70}</Project> // <Name>corlib-basic</Name> //</ProjectReference> //<ProjectReference Include="..\System\System-basic.csproj"> // <Project>{2094e859-db2f-481f-9630-f89d31d9ed48}</Project> // <Name>System-basic</Name> //</ProjectReference> var refdistinct = references.Distinct (); foreach (string r in refdistinct) { VsCsproj lastMatching = GetMatchingCsproj (Path.GetFileName (r), projects); if (lastMatching != null) { AddProjectReference (refs, result, lastMatching, r, null); } else { if (showWarnings){ Console.WriteLine ("{0}: Could not find a matching project reference for {1}", library, Path.GetFileName (r)); Console.WriteLine (" --> Adding reference with hintpath instead"); } refs.Append (" <Reference Include=\"" + r + "\">" + NewLine); refs.Append (" <SpecificVersion>False</SpecificVersion>" + NewLine); refs.Append (" <HintPath>" + r + "</HintPath>" + NewLine); refs.Append (" <Private>False</Private>" + NewLine); refs.Append (" </Reference>" + NewLine); } } foreach (string r in reference_aliases) { int index = r.IndexOf ('='); string alias = r.Substring (0, index); string assembly = r.Substring (index + 1); VsCsproj lastMatching = GetMatchingCsproj (Path.GetFileName (assembly), projects); if (lastMatching != null) { AddProjectReference (refs, result, lastMatching, r, alias); } else { throw new NotSupportedException (string.Format ("From {0}, could not find a matching project reference for {1}", library, r)); refs.Append (" <Reference Include=\"" + assembly + "\">" + NewLine); refs.Append (" <SpecificVersion>False</SpecificVersion>" + NewLine); refs.Append (" <HintPath>" + r + "</HintPath>" + NewLine); refs.Append (" <Aliases>" + alias + "</Aliases>" + NewLine); refs.Append (" </Reference>" + NewLine); } } } // Possible inputs: // ../class/lib/build/tmp/System.Xml.dll [No longer possible, we should be removing this from order.xml] // /class/lib/basic/System.Core.dll // <library_output>mcs.exe</library_output> string build_output_dir; if (library_output.Contains ("/")) build_output_dir = Path.GetDirectoryName (library_output); else build_output_dir = "bin\\Debug\\" + library; string postbuild_unix = string.Empty; string postbuild_windows = string.Empty; var postbuild = " <PostBuildEvent " + condition_unix + ">\n" + postbuild_unix + "\n </PostBuildEvent>\n" + " <PostBuildEvent " + condition_windows + ">\n" + postbuild_windows + "\n </PostBuildEvent>"; bool basic_or_build = (library.Contains ("-basic") || library.Contains ("-build")); // // Replace the template values // result.projectGuid = "{" + Guid.NewGuid ().ToString ().ToUpper () + "}"; result.library_output = library_output; result.fx_version = double.Parse (fx_version); result.output = template. Replace ("@PROJECTGUID@", result.projectGuid). Replace ("@DEFINES@", defines.ToString ()). Replace ("@DISABLEDWARNINGS@", string.Join (",", (from i in ignore_warning select i.ToString ()).ToArray ())). //Replace("@NOSTDLIB@", (basic_or_build || (!StdLib)) ? "<NoStdLib>true</NoStdLib>" : string.Empty). Replace ("@NOSTDLIB@", "<NoStdLib>" + (!StdLib).ToString () + "</NoStdLib>"). Replace ("@NOCONFIG@", "<NoConfig>" + (!load_default_config).ToString () + "</NoConfig>"). Replace ("@ALLOWUNSAFE@", Unsafe ? "<AllowUnsafeBlocks>true</AllowUnsafeBlocks>" : ""). Replace ("@FX_VERSION", fx_version). Replace ("@ASSEMBLYNAME@", Path.GetFileNameWithoutExtension (output_name)). Replace ("@OUTPUTDIR@", build_output_dir). Replace ("@DEFINECONSTANTS@", defines.ToString ()). Replace ("@DEBUG@", want_debugging_support ? "true" : "false"). Replace ("@DEBUGTYPE@", want_debugging_support ? "full" : "pdbonly"). Replace ("@REFERENCES@", refs.ToString ()). Replace ("@PREBUILD@", prebuild). Replace ("@POSTBUILD@", postbuild). //Replace ("@ADDITIONALLIBPATHS@", String.Format ("<AdditionalLibPaths>{0}</AdditionalLibPaths>", string.Join (",", libs.ToArray ()))). Replace ("@ADDITIONALLIBPATHS@", String.Empty). Replace ("@RESOURCES@", resources.ToString ()). Replace ("@OPTIMIZE@", Optimize ? "true" : "false"). Replace ("@SOURCES@", sources.ToString ()); //Console.WriteLine ("Generated {0}", ofile.Replace ("\\", "/")); var generatedProjFile = NativeName (result.csprojFileName); Console.WriteLine ("Generating: {0}", generatedProjFile); using (var o = new StreamWriter (generatedProjFile)) { o.WriteLine (result.output); } return result; }
void AddProjectReference (StringBuilder refs, VsCsproj result, MsbuildGenerator match, string r, string alias) { refs.AppendFormat (" <ProjectReference Include=\"{0}\">{1}", GetRelativePath (result.csProjFilename, match.CsprojFilename), NewLine); refs.Append (" <Project>" + match.projectGuid + "</Project>" + NewLine); refs.Append (" <Name>" + Path.GetFileNameWithoutExtension (match.CsprojFilename.Replace ('\\', Path.DirectorySeparatorChar)) + "</Name>" + NewLine); if (alias != null) refs.Append (" <Aliases>" + alias + "</Aliases>"); refs.Append (" </ProjectReference>" + NewLine); if (!result.projReferences.Contains (match.Csproj)) result.projReferences.Add (match.Csproj); }
public MsbuildGenerator (XElement xproject) { this.xproject = xproject; dir = xproject.Attribute ("dir").Value; library = xproject.Attribute ("library").Value; CsprojFilename = "..\\..\\mcs\\" + dir + "\\" + library + ".csproj"; LibraryOutput = xproject.Element ("library_output").Value; projectGuid = LookupOrGenerateGuid (); fx_version = xproject.Element ("fx_version").Value; Csproj = new VsCsproj () { csProjFilename = this.CsprojFilename, projectGuid = this.projectGuid, library_output = this.LibraryOutput, fx_version = double.Parse (fx_version), library = this.library, MsbuildGenerator = this }; if (dir == "mcs") { mcs_topdir = "../"; class_dir = "../class/"; base_dir = "../../mcs/mcs"; } else { mcs_topdir = "../"; foreach (char c in dir) { if (c == '/') mcs_topdir = "..//" + mcs_topdir; } class_dir = mcs_topdir.Substring (3); base_dir = Path.Combine ("..", "..", "mcs", dir); } AbsoluteLibraryOutput = Path.GetFullPath (Path.Combine (base_dir, LibraryOutput)); }
private void addProjectReference (StringBuilder refs, VsCsproj result, VsCsproj lastMatching, string r) { refs.AppendFormat (" <ProjectReference Include=\"{0}\">{1}", getRelativePath (result.csprojFileName, lastMatching.csprojFileName), NewLine); refs.Append (" <Project>" + lastMatching.projectGuid + "</Project>" + NewLine); refs.Append (" <Name>" + Path.GetFileNameWithoutExtension (lastMatching.csprojFileName) + "</Name>" + NewLine); //refs.Append(" <HintPath>" + r + "</HintPath>" + NewLine); refs.Append (" </ProjectReference>" + NewLine); if (!result.projReferences.Contains (lastMatching)) result.projReferences.Add (lastMatching); }