$ mcs -recurse:'*.cs'
.fi
.TP
+.I \-sdk:VERSION
+Used to specify the version of Base Class Library assemblies. The possible
+values are: 2 (default), 4. The version number means which .NET version
+should the produced assembly be compatible with.
+.TP
.I \-\-shell
Starts up the compiler in interactive mode, providing a C# shell for
statements and expressions. A shortcut is to use the
" --about About the Mono C# compiler\n" +
" -addmodule:M1[,Mn] Adds the module to the generated assembly\n" +
" -checked[+|-] Sets default aritmetic overflow context\n" +
- " -codepage:ID Sets code page to the one in ID (number, utf8, reset)\n" +
" -clscheck[+|-] Disables CLS Compliance verifications\n" +
+ " -codepage:ID Sets code page to the one in ID (number, utf8, reset)\n" +
" -define:S1[;S2] Defines one or more conditional symbols (short: -d)\n" +
" -debug[+|-], -g Generate debugging information\n" +
" -delaysign[+|-] Only insert the public key into the assembly (no signing)\n" +
" ARCH can be one of: anycpu, x86, x64 or itanium\n" +
" -recurse:SPEC Recursively compiles files according to SPEC pattern\n" +
" -reference:A1[,An] Imports metadata from the specified assembly (short: -r)\n" +
- " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" +
+ " -reference:ALIAS=A Imports metadata using specified extern alias (short: -r)\n" +
+ " -sdk:VERSION Specifies SDK version of referenced assemlies\n" +
+ " VERSION can be one of: 2 (default), 4\n" +
" -target:KIND Specifies the format of the output assembly (short: -t)\n" +
" KIND can be one of: exe, winexe, library, module\n" +
" -unsafe[+|-] Allows to compile code which uses unsafe keyword\n" +
return true;
+ case "/sdk":
+ if (value.Length == 0) {
+ Error_RequiresArgument (option);
+ break;
+ }
+
+ switch (value.ToLowerInvariant ()) {
+ case "2":
+ RootContext.SdkVersion = SdkVersion.v2;
+ break;
+ case "4":
+ RootContext.SdkVersion = SdkVersion.v4;
+ break;
+ default:
+ Report.Error (-26, "Invalid sdk version name");
+ break;
+ }
+
+ return true;
+
// We just ignore this.
case "/errorreport":
case "/filealign":
readonly Universe domain;
Assembly corlib;
List<Tuple<AssemblyName, string>> loaded_names;
+ static readonly Dictionary<SdkVersion, string[]> sdk_directory;
+
+ static StaticLoader ()
+ {
+ sdk_directory = new Dictionary<SdkVersion, string[]> ();
+ sdk_directory.Add (SdkVersion.v2, new string[] { "2.0", "net_2_0", "v2.0.50727" });
+ sdk_directory.Add (SdkVersion.v4, new string[] { "4.0", "net_4_0", "v4.0.30319" });
+ }
public StaticLoader (StaticImporter importer, CompilerContext compiler)
: base (compiler)
domain.AssemblyResolve += AssemblyReferenceResolver;
loaded_names = new List<Tuple<AssemblyName, string>> ();
- // TODO: profile specific
- paths.Add (Path.GetDirectoryName (typeof (object).Assembly.Location));
+ var corlib_path = Path.GetDirectoryName (typeof (object).Assembly.Location);
+ string fx_path = corlib_path.Substring (0, corlib_path.LastIndexOf (Path.DirectorySeparatorChar));
+ string sdk_path = null;
+
+ foreach (var dir in sdk_directory[RootContext.SdkVersion]) {
+ sdk_path = Path.Combine (fx_path, dir);
+ if (Directory.Exists (sdk_path))
+ break;
+
+ sdk_path = null;
+ }
+
+ if (sdk_path == null) {
+ compiler.Report.Warning (-1, 1, "SDK path could not be resolved");
+ } else {
+ paths.Add (sdk_path);
+ }
}
public Assembly Corlib {
}
}
+ if (Report.DebugFlags > 0)
+ Console.WriteLine ("Loading assembly `{0}'", fileName);
+
loaded_names.Add (Tuple.Create (an, fileName));
return domain.LoadAssembly (module);
}
continue;
try {
+ if (Report.DebugFlags > 0)
+ Console.WriteLine ("Loading default assembly `{0}'", file);
+
var a = domain.LoadFile (file);
if (a != null) {
loaded_names.Add (Tuple.Create (a.GetName (), assembly));
v4
}
+ public enum SdkVersion
+ {
+ v2,
+ v4
+ }
+
public enum Target
{
Library, Exe, Module, WinExe
public static LanguageVersion Version;
public static bool EnhancedWarnings;
public static bool LoadDefaultReferences;
+ public static SdkVersion SdkVersion;
//
// We keep strongname related info here because
MainClass = null;
OutputFile = null;
Target = Target.Exe;
+ SdkVersion = SdkVersion.v2;
TargetExt = ".exe";
Platform = Platform.AnyCPU;
Version = LanguageVersion.Default;