Пример #1
0
		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;
        }
Пример #2
0
		void MsVisitProjects(VisitProject visitor)
		{
			Engine e = new Engine(RuntimeEnvironment.GetRuntimeDirectory());
            if(e.GetType().Assembly.GetName().Version.Major == 2)
				try { e.GlobalProperties.SetProperty("MSBuildToolsPath", RuntimeEnvironment.GetRuntimeDirectory()); }
				catch { }

			foreach (FileInfo file in _projects)
			{
				Project prj = new Project(e);
				try
				{
					prj.Load(file.FullName);
				}
				catch (Exception ex)
				{
					Console.Error.WriteLine("Unable to open project: {0}", file);
					Log.Verbose(ex.ToString());
					continue;
				}

				visitor(new MsBuildProject(prj));
				e.UnloadProject(prj);
			}
		}
Пример #3
0
        private string InitRuntime(string toolsVersion, string frameworkDir, bool hardReferences)
		{
			_items = new ItemLookup();
			_toolsVersion = toolsVersion;
			_engine = new Engine( frameworkDir );

			Log.Verbose("Using build engine: {0}", _engine.GetType().Assembly.FullName);
			string version = _engine.GetType().Assembly.GetName().Version.ToString(2);
			Is35 = version == "3.5";

            if (hardReferences)
            {
                _engine.GlobalProperties.SetProperty("AssemblySearchPaths", "{HintPathFromItem}");
                //{CandidateAssemblyFiles}
                //{HintPathFromItem}
                //{TargetFrameworkDirectory}
                //{Registry:Software\Microsoft\.NetFramework,v2.0,AssemblyFoldersEx}
                //{AssemblyFolders}
                //{GAC}
                //{RawFileName}
                //$(OutputPath)

                _engine.GlobalProperties.SetProperty("NoStdLib", true.ToString());
            }
			if( !Is35 )
				_engine.GlobalProperties.SetProperty("MSBuildToolsPath", frameworkDir);

			ConsoleLogger trace = new Microsoft.Build.BuildEngine.ConsoleLogger(
					LoggerVerbosity.Minimal, ConsoleWrite, ColorSetter, ColorResetter
				);
			trace.SkipProjectStartedText = false;
			trace.ShowSummary = false;
			_engine.RegisterLogger(trace);

			return version;
		}