protected override int Run(BuildEngine engine) { FrameworkVersions currentTools = engine.Framework; foreach (ProjectInfo item in engine.Projects) { FrameworkVersions myFramework = currentTools; string projFramework = item.Properties[MSProp.TargetFrameworkVersion]; if (!String.IsNullOrEmpty(projFramework)) { myFramework = (FrameworkVersions)Enum.Parse(typeof(FrameworkVersions), projFramework.Replace(".", "")); } foreach (ReferenceInfo r in item.References) { if (r.RequiresVersion != null) { if (r.RequiresVersion.Value > myFramework) { item.References.Remove(r); } } } } return(0); }
internal static string MakeFrameworkBinPath(FrameworkVersions framework) { string frmwrk; switch (framework) { case FrameworkVersions.v20: case FrameworkVersions.v30: frmwrk = "v2.0.50727"; break; case FrameworkVersions.v35: frmwrk = "v3.5"; break; case FrameworkVersions.v40: case FrameworkVersions.v45: frmwrk = "v4.0.30319"; break; default: throw new ArgumentException("Unknown framework version: " + framework); } string windir = Environment.GetFolderPath(Environment.SpecialFolder.System); string msbuild = Path.Combine(windir, String.Format(@"..\Microsoft.NET\Framework\{0}\MSBuild.exe", frmwrk)); if (!File.Exists(msbuild)) { throw new FileNotFoundException("MSBuild.exe not found.", msbuild); } return(Path.GetFullPath(Path.GetDirectoryName(msbuild))); }
private static Engine CreateEngine(FrameworkVersions toolsVersion, string frameworkPath) { Engine engine = new Engine(frameworkPath); Version fullVersion = engine.GetType().Assembly.GetName().Version; string version = fullVersion.ToString(2); if (toolsVersion == FrameworkVersions.v30 && version == "2.0") version = "3.0";//these use the same build runtime: 2.0/3.0 if (toolsVersion == FrameworkVersions.v45 && version == "4.0") version = "4.5";//these use the same build runtime: 4.0/4.5 if (version.Replace(".", "") != toolsVersion.ToString().TrimStart('v')) throw new ApplicationException(String.Format("Expected runtime {0}, found ({1}){2}.", toolsVersion, version, fullVersion)); Log.Verbose("Using build engine: {0}", engine.GetType().Assembly.FullName); if (toolsVersion == FrameworkVersions.v20 || toolsVersion == FrameworkVersions.v30) engine.GlobalProperties.SetProperty("MSBuildToolsPath", frameworkPath); //<property name="FrameworkSDKDir" value="%ProgramFiles%\Microsoft.NET\SDK\v2.0\" global="true"/> //if (!Directory.Exists(engine.GlobalProperties.SetProperty())) //{ } new MSBuildLog(engine); return engine; }
private static Engine CreateEngine(FrameworkVersions toolsVersion, string frameworkPath) { Engine engine = new Engine(frameworkPath); Version fullVersion = engine.GetType().Assembly.GetName().Version; string version = fullVersion.ToString(2); if (toolsVersion == FrameworkVersions.v30 && version == "2.0") { version = "3.0"; //these use the same build runtime: 2.0/3.0 } if (toolsVersion == FrameworkVersions.v45 && version == "4.0") { version = "4.5";//these use the same build runtime: 4.0/4.5 } if (version.Replace(".", "") != toolsVersion.ToString().TrimStart('v')) { throw new ApplicationException(String.Format("Expected runtime {0}, found ({1}){2}.", toolsVersion, version, fullVersion)); } Log.Verbose("Using build engine: {0}", engine.GetType().Assembly.FullName); if (toolsVersion == FrameworkVersions.v20 || toolsVersion == FrameworkVersions.v30) { engine.GlobalProperties.SetProperty("MSBuildToolsPath", frameworkPath); } //<property name="FrameworkSDKDir" value="%ProgramFiles%\Microsoft.NET\SDK\v2.0\" global="true"/> //if (!Directory.Exists(engine.GlobalProperties.SetProperty())) //{ } new MSBuildLog(engine); return(engine); }
public BuildEngine(FrameworkVersions toolsVersion, string frameworkPath) { _framework = toolsVersion; _frameworkPath = frameworkPath; Engine = CreateEngine(_framework, _frameworkPath); _projects = new ProjectList(this, _framework); _properties = new PropertyList(Engine.GlobalProperties); }
public EnforceReferences(FrameworkVersions framework, IDictionary <String, String> namedValues, bool strictReferences, bool noStdLib, bool noProjectReferences) { _framework = framework; _namedValues = namedValues; _strict = strictReferences; _noStdLib = noStdLib; _noprojectrefs = noProjectReferences; }
public EnforceReferences(FrameworkVersions framework, IDictionary<String, String> namedValues, bool strictReferences, bool noStdLib, bool noProjectReferences) { _framework = framework; _namedValues = namedValues; _strict = strictReferences; _noStdLib = noStdLib; _noprojectrefs = noProjectReferences; }
BuildEngine CreateEngine(FrameworkVersions toolsVersion) { string dir = Util.MakeFrameworkBinPath(toolsVersion); //if (!CSBuildConfig.ToDictionary(_properties).TryGetValue("FrameworkBIN" + _framework, out dir)) BuildEngine engine = new BuildEngine(toolsVersion, dir); return(engine); }
private static string GetConfigPath(FrameworkVersions toolsVersion) { string config = String.Format("CSharpTest.Net.CSBuild.{0}.config", toolsVersion.ToString()); using (TextReader rdr = new StreamReader(typeof(BuildEngine).Assembly.GetManifestResourceStream(config))) config = rdr.ReadToEnd(); string tmpConfig = Path.Combine(Path.GetTempPath(), String.Format("CSBuildEngine.{0}.config", toolsVersion.ToString())); File.WriteAllText(tmpConfig, config); return tmpConfig; }
private static string GetConfigPath(FrameworkVersions toolsVersion) { string config = String.Format("CSharpTest.Net.CSBuild.{0}.config", toolsVersion.ToString()); using (TextReader rdr = new StreamReader(typeof(BuildEngine).Assembly.GetManifestResourceStream(config))) config = rdr.ReadToEnd(); string tmpConfig = Path.Combine(Path.GetTempPath(), String.Format("CSBuildEngine.{0}.config", toolsVersion.ToString())); File.WriteAllText(tmpConfig, config); return(tmpConfig); }
/// <summary> /// Check if a specific .NET Framework version is installed. /// </summary> /// <param name="version">version to test</param> /// <returns>True if installed</returns> public static bool IsVersionInstalled(FrameworkVersions version) { try { switch (version) { case FrameworkVersions.Mono_2_4: if (!string.IsNullOrEmpty(MonoVersion)) { Regex regex = new Regex(@"^Mono (?<major>\d+)\.(?<minor>\d+)(\..*)?$"); if (regex.IsMatch(MonoVersion)) { string[] items = regex.Split(MonoVersion); int major = Convert.ToInt32(items[regex.GroupNumberFromName("major")]); int minor = Convert.ToInt32(items[regex.GroupNumberFromName("minor")]); return((major == 2 && minor >= 4) || (major >= 3)); } } break; default: RegistryKey masterKey = Registry.LocalMachine.OpenSubKey(REG_LOCATION); if (masterKey != null) { string[] SubKeyNames = masterKey.GetSubKeyNames(); foreach (string ver in SubKeyNames) { if (ver.ToLower().Replace(".", "_") == version.ToString()) { return(true); } } } break; } } catch (Exception) { } return(false); }
/// <summary> /// Check if a specific .NET Framework version is installed. /// </summary> /// <param name="version">version to test</param> /// <returns>True if installed</returns> public static bool IsVersionInstalled(FrameworkVersions version) { try { switch (version) { case FrameworkVersions.Mono_2_4: if (!string.IsNullOrEmpty(MonoVersion)) { Regex regex = new Regex(@"^Mono (?<major>\d+)\.(?<minor>\d+)(\..*)?$"); if (regex.IsMatch(MonoVersion)) { string[] items = regex.Split(MonoVersion); int major = Convert.ToInt32(items[regex.GroupNumberFromName("major")]); int minor = Convert.ToInt32(items[regex.GroupNumberFromName("minor")]); return (major == 2 && minor >= 4) || (major >= 3); } } break; default: RegistryKey masterKey = Registry.LocalMachine.OpenSubKey(REG_LOCATION); if (masterKey != null) { string[] SubKeyNames = masterKey.GetSubKeyNames(); foreach (string ver in SubKeyNames) { if (ver.ToLower().Replace(".", "_") == version.ToString()) { return true; } } } break; } } catch (Exception) { } return false; }
public static BuildDomain CreateInstance(FrameworkVersions toolsVersion, string[] properties) { AppDomainSetup setup = new AppDomainSetup(); setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; setup.ApplicationName = String.Format("CSBuildEngine.{0}", toolsVersion); setup.ConfigurationFile = GetConfigPath(toolsVersion); setup.DisallowBindingRedirects = false; Log.Verbose("Constructing AppDomain for build: {0}, version = {1}", setup.ApplicationName, toolsVersion); AppDomain domain = AppDomain.CreateDomain(setup.ApplicationName, AppDomain.CurrentDomain.Evidence, setup); RemoteDomain instance = (RemoteDomain)domain.CreateInstanceAndUnwrap(typeof(RemoteDomain).Assembly.FullName, typeof(RemoteDomain).FullName); instance.Framework = toolsVersion; instance.Properties = properties; instance.SetLog(Log.TextWriter, Log.ConsoleLevel); return new BuildDomain(domain, instance, toolsVersion); }
public static BuildDomain CreateInstance(FrameworkVersions toolsVersion, string[] properties) { AppDomainSetup setup = new AppDomainSetup(); setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; setup.ApplicationName = String.Format("CSBuildEngine.{0}", toolsVersion); setup.ConfigurationFile = GetConfigPath(toolsVersion); setup.DisallowBindingRedirects = false; Log.Verbose("Constructing AppDomain for build: {0}, version = {1}", setup.ApplicationName, toolsVersion); AppDomain domain = AppDomain.CreateDomain(setup.ApplicationName, AppDomain.CurrentDomain.Evidence, setup); RemoteDomain instance = (RemoteDomain)domain.CreateInstanceAndUnwrap(typeof(RemoteDomain).Assembly.FullName, typeof(RemoteDomain).FullName); instance.Framework = toolsVersion; instance.Properties = properties; instance.SetLog(Log.TextWriter, Log.ConsoleLevel); return(new BuildDomain(domain, instance, toolsVersion)); }
private static string GetFrameworksInstalled() { List <FrameworkVersions.VersionInfo> fws; // log.Debug("var f1ws = FrameworkVersions.GetInstalledVersions().ToList();"); try { fws = FrameworkVersions.GetInstalledVersions().ToList(); } catch (Exception ex) { return(string.Format(Program.Model.LocaleManager.GetLocalizedText("frmComponents", "frameworkVersionErrorPattern"), ex.Message)); } // log.Debug("return string.Join(Nl, fws.OrderBy(fw => fw.Version).Select(fw => fw.ToString()));"); return(string.Join(Environment.NewLine, fws.OrderBy(fw => fw.Version).Select(fw => fw.ToString()))); }
BuildEngine CreateEngine(FrameworkVersions toolsVersion) { string dir = Util.MakeFrameworkBinPath(toolsVersion); //if (!CSBuildConfig.ToDictionary(_properties).TryGetValue("FrameworkBIN" + _framework, out dir)) BuildEngine engine = new BuildEngine(toolsVersion, dir); return engine; }
private BuildDomain(AppDomain domain, RemoteDomain instance, FrameworkVersions toolsVersion) { _domain = domain; _instance = instance; _framework = toolsVersion; }
internal static string MakeFrameworkBinPath(FrameworkVersions framework) { string frmwrk; switch (framework) { case FrameworkVersions.v20: case FrameworkVersions.v30: frmwrk = "v2.0.50727"; break; case FrameworkVersions.v35: frmwrk = "v3.5"; break; case FrameworkVersions.v40: case FrameworkVersions.v45: frmwrk = "v4.0.30319"; break; default: throw new ArgumentException("Unknown framework version: " + framework); } string windir = Environment.GetFolderPath(Environment.SpecialFolder.System); string msbuild = Path.Combine(windir, String.Format(@"..\Microsoft.NET\Framework\{0}\MSBuild.exe", frmwrk)); if (!File.Exists(msbuild)) throw new FileNotFoundException("MSBuild.exe not found.", msbuild); return Path.GetFullPath(Path.GetDirectoryName(msbuild)); }
public ProjectList(BuildEngine engine, FrameworkVersions framework) { this.Engine = engine; _framework = framework; }
public RemoteDomain() { _framework = FrameworkVersions.v20; //AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); }