コード例 #1
0
        public MSBuildConfiguration(MSBuildProject project, NAnt.MSBuild.BuildEngine.Project msproj, Configuration projectConfig)
            : base(project)
        {
            _name = projectConfig.Name;
            _platform = projectConfig.Platform;

            //explicit set. EvaluatedProperties will use those.
            //Its caller responsibility to set it back to original values, if needed
            msproj.GlobalProperties.SetProperty("Configuration", _name);

            if (!String.IsNullOrEmpty(_platform)) {
                msproj.GlobalProperties.SetProperty("Platform", _platform.Replace(" ", string.Empty));
            }

            _relativeOutputDir = msproj.GetEvaluatedProperty("OutputPath");
            if (!_relativeOutputDir.EndsWith(Path.DirectorySeparatorChar.ToString(CultureInfo.InvariantCulture))) {
                _relativeOutputDir = _relativeOutputDir + Path.DirectorySeparatorChar;
            }
            _outputDir = new DirectoryInfo(FileUtils.CombinePaths(
                project.ProjectDirectory.FullName,
                _relativeOutputDir));

            _objdir = new DirectoryInfo(msproj.GetEvaluatedProperty("IntermediateOutputPath"));

            _outputType = GetType(msproj.GetEvaluatedProperty("OutputType"));
            _asmname = msproj.GetEvaluatedProperty("AssemblyName");
        }
コード例 #2
0
 protected InstallerCreationCommand(MSIBase msi, NAnt.Core.Task task, Location location, XmlNode node) {
     this.msi = msi;
     this.task = task;
     this.location = location;
     this.node = node;
     guidCounter = msi.output.GetHashCode();
 }
コード例 #3
0
ファイル: Engine.cs プロジェクト: TheGreatMasterG/nant
        public static Engine LoadEngine(NAnt.Core.FrameworkInfo framework)
        {
            //System.AppDomainSetup myDomainSetup = new System.AppDomainSetup();
            //myDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
            //myDomainSetup.ApplicationName = "MSBuild";

            //string tempFile = Path.GetTempFileName();
            //using (StreamWriter sw = File.CreateText(tempFile))
            //{
            //    sw.WriteLine(String.Format(
            //        "<?xml version='1.0'?><configuration><runtime>"
            //        + "<assemblyBinding xmlns='urn:schemas-microsoft-com:asm.v1'>"
            //        + "<dependentAssembly><assemblyIdentity name='Microsoft.Build.Framework' publicKeyToken='b03f5f7f11d50a3a' culture='neutral'/><bindingRedirect oldVersion='0.0.0.0-99.9.9.9' newVersion='{0}'/></dependentAssembly>"
            //        + "<dependentAssembly><assemblyIdentity name='Microsoft.Build.Engine' publicKeyToken='b03f5f7f11d50a3a' culture='neutral'/><bindingRedirect oldVersion='0.0.0.0-99.9.9.9' newVersion='{0}'/></dependentAssembly>"
            //        + "</assemblyBinding></runtime></configuration>",
            //        new Version(framework.Version.Major, framework.Version.Minor, 0, 0)));
            //}

            //myDomainSetup.ConfigurationFile = tempFile;// AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

            //var executionAD = AppDomain.CreateDomain(myDomainSetup.ApplicationName,
            //    AppDomain.CurrentDomain.Evidence, myDomainSetup);
            //AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(CurrentDomain_AssemblyLoad);
            //executionAD.AssemblyLoad += new AssemblyLoadEventHandler(executionAD_AssemblyLoad);

            //LongPathFile.Delete(tempFile);

            //Loader l = (Loader)executionAD.CreateInstanceAndUnwrap(typeof(Loader).Assembly.FullName, typeof(Loader).FullName);
            Loader l = new Loader();
            l.framework = framework;
            //executionAD.DoCallBack(new CrossAppDomainDelegate(l.DoLoad));
            l.DoLoad();
            return l.engine;
        }
コード例 #4
0
ファイル: MSBuildEngine.cs プロジェクト: RoastBoy/nant
        public static NAnt.MSBuild.BuildEngine.Engine CreateMSEngine(NAnt.VSNet.Tasks.SolutionTask solutionTask) {
            if (_msbuild!=null) {
                return _msbuild;
            }

            try {
                _msbuild = NAnt.MSBuild.BuildEngine.Engine.LoadEngine(solutionTask.Project.TargetFramework);
            } catch (Exception e) {
                throw new BuildException(
                    String.Format(
                        "MSBuild v{0} can't be found. It is needed for building MSBuild projects. VS2005 and later is using MSBuild projects for C# and VB",
                        solutionTask.Project.TargetFramework.Version),
                    Location.UnknownLocation, e);
            }
            _msbuild.UnregisterAllLoggers();

            NAntLoggerVerbosity _verbosity = solutionTask.Verbose ? NAntLoggerVerbosity.Normal : NAntLoggerVerbosity.Minimal;
            NAntLogger _logger = NAntLogger.Create(solutionTask.Project.TargetFramework, solutionTask, _verbosity, _msbuild);
            if (_logger != null) {
                _msbuild.RegisterLogger(_logger);
            }
            
            solutionTask.Log(Level.Verbose, "Using MSBuild version {0}.", FileVersionInfo.GetVersionInfo(_msbuild.Assembly.Location).ProductVersion);

            return _msbuild;
        }
コード例 #5
0
ファイル: NAntLogger.cs プロジェクト: RoastBoy/nant
        internal static NAntLogger Create(NAnt.Core.FrameworkInfo framework, Task task, NAntLoggerVerbosity verbosity, NAnt.MSBuild.BuildEngine.Engine engine) {
            CodeDomProvider codeDomProvider = CodeDomProvider.CreateProvider("C#");
            CompilerParameters par = new CompilerParameters();
            AssemblyName msbuildFrameworkName = engine.Assembly.GetName();
            msbuildFrameworkName.Name = "Microsoft.Build.Framework";
            Assembly msbuildFramework = Assembly.Load(msbuildFrameworkName);

            par.ReferencedAssemblies.Add(msbuildFramework.Location);
            par.ReferencedAssemblies.Add(typeof(NAnt.Core.Task).Assembly.Location);
            par.ReferencedAssemblies.Add(typeof(NAntLogger).Assembly.Location);
            par.GenerateInMemory = true;
            CompilerResults res = codeDomProvider.CompileAssemblyFromSource(par, _impl);
            if (res.Errors.HasErrors) {
                return null;
            }

            Type t = res.CompiledAssembly.GetType("NAntLoggerImpl");
            return (NAntLogger)Activator.CreateInstance(t, task, verbosity);
        }
コード例 #6
0
ファイル: MSBuildEngine.cs プロジェクト: smaclell/NAnt
        public static Microsoft.Build.BuildEngine.Engine CreateMSEngine(NAnt.VSNet.Tasks.SolutionTask solutionTask)
        {
            if (_msbuild!=null) {
                return _msbuild;
            }

            // map current target framework to TargetDotNetFrameworkVersion
            TargetDotNetFrameworkVersion frameworkVersion = GetTargetDotNetFrameworkVersion(
                solutionTask.Project.TargetFramework);

            // use the framework directory as BinPath
            string frameworkDir = ToolLocationHelper.GetPathToDotNetFramework(
                frameworkVersion);

            _msbuild = new Microsoft.Build.BuildEngine.Engine(frameworkDir);
            _msbuild.UnregisterAllLoggers();

            _msbuild.RegisterLogger(
                new NAntLogger(solutionTask,
                solutionTask.Verbose ? Microsoft.Build.Framework.LoggerVerbosity.Normal : Microsoft.Build.Framework.LoggerVerbosity.Minimal
                )
                );

            /*
            foreach (PropertyTask property in solutionTask.CustomProperties) {
                string val;
                // expand properties in context of current project for non-dynamic properties
                if (!property.Dynamic) {
                    val = solutionTask.Project.ExpandProperties(property.Value, solutionTask.Location);
                }
                else
                    val = property.Value;
                _msbuild.GlobalProperties.SetProperty(property.PropertyName, val);
            }
            */

            return _msbuild;
        }
コード例 #7
0
 private void GenerateSolutionFile(NAnt.Core.Project Project)
 {
     var solutionPath = new FileInfo(String.Format(
             "{0}{1}_{2}.sln",
             new FileInfo(Project.BuildFileLocalName).DirectoryName,
             Path.DirectorySeparatorChar,
             Project.ProjectName));
     using (var solution = solutionPath.CreateText())
     {
         solution.WriteLine(@"Microsoft Visual Studio Solution File, Format Version 11.00");
         solution.WriteLine("# Visual Studio 2010");
         foreach (var project in projectOutputs.Values)
         {
             solution.WriteLine(
                 "Project(\"{0:B}\") = \"{1}\", \"{2}\", \"{3:B}\"",
                 project.GetTypeId(),
                 project.GetAssemblyName(),
                 new FileInfo(project.FullPath).GetPathRelativeTo(solutionPath.Directory),
                 project.GetProjectId());
             solution.WriteLine("EndProject");
         }
         solution.WriteLine("Project(\"{2150E333-8FDC-42A3-9474-1A3956D46DE8}\") = \"Solution Items\", \"Solution Items\", \"{4D8FAB75-E6D2-4581-B7F0-BB11BCCEE0CA}\"");
         solution.WriteLine("	ProjectSection(SolutionItems) = preProject");
         solution.WriteLine("		{0} = {0}", new FileInfo(Project.BuildFileLocalName).GetPathRelativeTo(solutionPath.Directory));
         solution.WriteLine("	EndProjectSection");
         solution.WriteLine("EndProject");
     }
 }
コード例 #8
0
        /*
         * Methods to support moving away from a NAnt.Core.Task subclass
         */

        protected void Log(NAnt.Core.Level messageLevel, string message, params object[] args) {
            task.Log(messageLevel, message, args);
        }