Esempio n. 1
0
        public XnaContentProject(Task task, string msBuildPath, string xnaInstallPath)
        {
            m_engine = new Engine(msBuildPath);
            m_engine.RegisterLogger(new XnaContentLogger(task));
            m_project = new Project(m_engine);

            m_project.AddNewUsingTaskFromAssemblyName("BuildContent", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");
            m_project.AddNewUsingTaskFromAssemblyName("BuildXact", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");

            // Add our Content Pipeline Assemblies
            m_pipelineGroup = m_project.AddNewItemGroup();
            m_contentGroup  = m_project.AddNewItemGroup();

            m_contentTarget = m_project.Targets.AddNewTarget("_BuildXNAContentLists");

            // Add our Build target
            m_xnaTarget = m_project.Targets.AddNewTarget("Build");
            m_xnaTarget.DependsOnTargets = "_BuildXNAContentLists";

            // Add Default Pipeline Assemblies.
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll");
        }
Esempio n. 2
0
        public XnaContentProject(Task task, string msBuildPath, string xnaInstallPath)
        {
            m_engine = new Engine(msBuildPath);
            m_engine.RegisterLogger(new XnaContentLogger(task));
            m_project = new Project(m_engine);

            m_project.AddNewUsingTaskFromAssemblyName("BuildContent", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");
            m_project.AddNewUsingTaskFromAssemblyName("BuildXact", "Microsoft.Xna.Framework.Content.Pipeline, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d");

            // Add our Content Pipeline Assemblies
            m_pipelineGroup = m_project.AddNewItemGroup();
            m_contentGroup = m_project.AddNewItemGroup();

            m_contentTarget = m_project.Targets.AddNewTarget("_BuildXNAContentLists");

            // Add our Build target
            m_xnaTarget = m_project.Targets.AddNewTarget("Build");
            m_xnaTarget.DependsOnTargets = "_BuildXNAContentLists";

            // Add Default Pipeline Assemblies.
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll");
            AddPilepineAssembly(xnaInstallPath + "Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll");
        }
Esempio n. 3
0
 public void GetAssemblyNameScalarThatIsNotSet()
 {
     Project p = new Project(new Engine());
     p.AddNewUsingTaskFromAssemblyName("TaskName", @"$(assemblyName)");
     object o = p.EvaluatedItems;
     Assertion.AssertEquals(@"$(assemblyName)", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName);
 }
Esempio n. 4
0
 public void GetAssemblyNameSpecialChars()
 {
     Project p = new Project();
     p.AddNewUsingTaskFromAssemblyName("TaskName", @"%*?@$();\");
     object o = p.EvaluatedItems;
     Assertion.AssertEquals(@"%*?@$();\", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName);
 }
Esempio n. 5
0
 public void GetAssemblyNameSpecialCharsEscaped()
 {
     Project p = new Project(new Engine());
     p.AddNewUsingTaskFromAssemblyName("TaskName", @"%25%2a%3f%40%24%28%29%3b\");
     object o = p.EvaluatedItems;
     Assertion.AssertEquals(@"%25%2a%3f%40%24%28%29%3b\", CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName);
 }
 public void Count_IncrementOnAddName()
 {
     Project p = new Project(new Engine());
     Assertion.AssertEquals(0, p.UsingTasks.Count);
     p.AddNewUsingTaskFromAssemblyName("TaskName", "AssemblyName");
     Assertion.AssertEquals(0, p.UsingTasks.Count);
     object o = p.EvaluatedProperties;
     Assertion.AssertEquals(1, p.UsingTasks.Count);
 }
Esempio n. 7
0
        public void MopUp(Project project)
        {
            foreach (var t in tasks.Where(td=>!td.ScriptIsSet))
              {
            var scr = scripts.FirstOrDefault(s => s.ScriptName.Equals(t.ScriptName));
            if (scr == null)
              throw new ArgumentNullException("Access to undefined script " + t.ScriptName);
            t.SetScript(scr.Script);
              }

              if (tasks.Count > 0)
            project.AddNewUsingTaskFromAssemblyName("RunScript", GetType().Assembly.FullName);
        }
Esempio n. 8
0
 public void GetAssemblyNameScalarEvaluation()
 {
     string assemblyName = "$(assemblyName)";
     Project p = new Project();
     p.SetProperty("assemblyName", "aName");
     object o = p.EvaluatedItems;
     p.AddNewUsingTaskFromAssemblyName("TaskName", assemblyName);
     o = p.EvaluatedItems;
     Assertion.AssertEquals(assemblyName, CompatibilityTestHelpers.FindUsingTaskByName("TaskName", p.UsingTasks).AssemblyName);
 }
Esempio n. 9
0
 public void GetTaskNameSpeicalCharsEscaped()
 {
     Project p = new Project(new Engine());
     p.AddNewUsingTaskFromAssemblyName(@"%25%2a%3f%40%24%28%29%3b\", "assemblyName");
     object o = p.EvaluatedItems;
     Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName(@"%25%2a%3f%40%24%28%29%3b\", p.UsingTasks));
 }
Esempio n. 10
0
 public void GetTaskNameSpeicalChars()
 {
     Project p = new Project();
     p.AddNewUsingTaskFromAssemblyName(@"%*?@$();\", "assemblyName");
     object o = p.EvaluatedItems;
     Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName(@"%*?@$();\", p.UsingTasks));
 }
Esempio n. 11
0
 public void GetTaskNameScalar()
 {
     Project p = new Project(new Engine());
     p.AddNewUsingTaskFromAssemblyName("$(name)", "assemblyName");
     p.SetProperty("name", "TaskName");
     object o = p.EvaluatedItems;
     Assertion.AssertNotNull(CompatibilityTestHelpers.FindUsingTaskByName("$(name)", p.UsingTasks));
 }
Esempio n. 12
0
        /// <summary>
        /// Given an empty project and a solution, create a new solution project from the solution.
        /// </summary>
        private static void CreateSolutionProject(SolutionParser solution, Project msbuildProject, BuildEventContext projectBuildEventContext, string wrapperProjectToolsVersion, Engine parentEngine, string solutionProjectCache)
        {
            // We have to figure out what tools version the children will be built with, because we will 
            // have to load and scan them to construct the solution wrapper project, and we should use the 
            // same tools version they'll build with.
            string childProjectToolsVersion = DetermineChildProjectToolsVersion(parentEngine, wrapperProjectToolsVersion);

            string taskAssembly;

            if (String.Equals(msbuildProject.ToolsVersion, "2.0", StringComparison.OrdinalIgnoreCase))
            {
                taskAssembly = "Microsoft.Build.Tasks, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            }
            else
            {
                taskAssembly = "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
            }

            // Fully qualified class names are more performant
            msbuildProject.AddNewUsingTaskFromAssemblyName("Microsoft.Build.Tasks.CreateTemporaryVCProject", taskAssembly);
            msbuildProject.AddNewUsingTaskFromAssemblyName("Microsoft.Build.Tasks.ResolveVCProjectOutput", taskAssembly);

            AddFakeReleaseSolutionConfigurationIfNecessary(solution);

            Dictionary<int, List<ProjectInSolution>> projectsByDependencyLevel = new Dictionary<int, List<ProjectInSolution>>();

            string fullSolutionConfigurationName = PredictActiveSolutionConfigurationName(solution, parentEngine);

            ScanProjectDependencies(solution, parentEngine, childProjectToolsVersion, fullSolutionConfigurationName, projectBuildEventContext);
            ConvertVcToVcDependenciesToReferences(solution, parentEngine, projectBuildEventContext);
            AssignDependencyLevels(solution, projectsByDependencyLevel);
            AddVirtualReferencesForStaticLibraries(solution);

            // Add config, platform and tools version to indicate relevance of cache
            AddCacheRelatedProperties(msbuildProject, fullSolutionConfigurationName, wrapperProjectToolsVersion, solution.ProjectsInOrder);

            // Add default solution configuration/platform names in case the user doesn't specify them on the command line
            AddConfigurationPlatformDefaults(msbuildProject, solution);

            // Add default Venus configuration names (for more details, see comments for this method)
            AddVenusConfigurationDefaults(msbuildProject);

            // Add solution related macros
            AddGlobalProperties(msbuildProject, solution);

            // Add a property group for each solution configuration, each with one XML property containing the
            // project configurations in this solution configuration.
            foreach (ConfigurationInSolution solutionConfiguration in solution.SolutionConfigurations)
            {
                AddPropertyGroupForSolutionConfiguration(msbuildProject, solution, solutionConfiguration);
            }

            // Add the initial target with some solution configuration validation/information
            // Only do it if we actually have any solution configurations...
            if (solution.SolutionConfigurations.Count > 0)
            {
                AddInitialTargets(msbuildProject);
            }

            // Add a <target> element for each project we have
            foreach (ProjectInSolution proj in solution.ProjectsInOrder)
            {
                string errorMessage = null;

                // is it a solution folder?
                if (proj.ProjectType == SolutionProjectType.SolutionFolder)
                {
                    // Don't add any targets. Solution folder "projects" aren't actually projects at all and should be ignored.
                }
                else if (proj.ProjectType == SolutionProjectType.WebProject)
                {
                    AddTargetForWebProject(msbuildProject, solution, proj, null);
                    AddTargetForWebProject(msbuildProject, solution, proj, "Clean");
                    AddTargetForWebProject(msbuildProject, solution, proj, "Rebuild");
                    AddTargetForWebProject(msbuildProject, solution, proj, "Publish");
                }
                else if (proj.ProjectType == SolutionProjectType.VCProject)
                {
                    AddTargetForVCProject(msbuildProject, solution, proj, null);
                    AddTargetForVCProject(msbuildProject, solution, proj, "Clean");
                    AddTargetForVCProject(msbuildProject, solution, proj, "Rebuild");
                    AddTargetForVCProject(msbuildProject, solution, proj, "Publish");
                }
                // is it an MSBuild project?
                else if ((proj.ProjectType == SolutionProjectType.ManagedProject) ||
                         (proj.CanBeMSBuildProjectFile(out errorMessage)))
                {
                    string safeItemNameFromProjectName = MakeIntoSafeItemName(proj.ProjectName);
                    string targetOutputItemName = string.Format(CultureInfo.InvariantCulture, "{0}BuildOutput", safeItemNameFromProjectName);
                    AddTargetForManagedProject(msbuildProject, solution, proj, targetOutputItemName, null);
                    AddTargetForManagedProject(msbuildProject, solution, proj, null, "Clean");
                    AddTargetForManagedProject(msbuildProject, solution, proj, targetOutputItemName, "Rebuild");
                    AddTargetForManagedProject(msbuildProject, solution, proj, null, "Publish");
                }
                else
                {
                    AddTargetForUnknownProjectType(msbuildProject, solution, proj, null, errorMessage);
                    AddTargetForUnknownProjectType(msbuildProject, solution, proj, "Clean", errorMessage);
                    AddTargetForUnknownProjectType(msbuildProject, solution, proj, "Rebuild", errorMessage);
                    AddTargetForUnknownProjectType(msbuildProject, solution, proj, "Publish", errorMessage);
                }
            }

            // Add a target called "Build" that depends on all the other projects.  This will be the
            // default target that is invoked when the "project" is built.
            AddAllDependencyTarget(msbuildProject, "Build", "CollectedBuildOutput", null, projectsByDependencyLevel);
            Target cleanTarget = AddAllDependencyTarget(msbuildProject, "Clean", null, "Clean", projectsByDependencyLevel);

            // As far as cleaning the solution project cache (if any) goes, we can't do it easily, because by the time we know we
            // need to do a clean, we've already loaded the cache. Instead, at the end of a solution clean, we'll delete the cache
            // file if any. A solution rebuild won't delete the cache, because probably one would expect a rebuild to leave it behind.
            if (IsSolutionCacheEnabled())
            {
                BuildTask deleteTask = cleanTarget.AddNewTask("Delete");
                // Don't use $(MSBuildProjectFile) for safety, in case user has copied and re-purposed this cache file
                deleteTask.SetParameterValue("Files", Path.GetFileName(solutionProjectCache));
            }

            AddAllDependencyTarget(msbuildProject, "Rebuild", "CollectedBuildOutput", "Rebuild", projectsByDependencyLevel);
            AddAllDependencyTarget(msbuildProject, "Publish", null, "Publish", projectsByDependencyLevel);

            // Special environment variable to allow people to see the in-memory MSBuild project generated
            // to represent the SLN.
            if (Environment.GetEnvironmentVariable("MSBuildEmitSolution") != null)
            {
                msbuildProject.Save(solution.SolutionFile + ".proj");
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:TaskComposer"/> class
        /// with a logger.
        /// </summary>
        /// <param name="project">The build project the task should use.</param>
        /// <param name="taskType">Type of the task to compose.</param>
        /// <param name="buildLogger">The logger to use. Can be null.</param>
        public TaskComposer(Project project, Type taskType, IBuildLogger buildLogger)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            this.project = project;

            if (taskType == null)
            {
                throw new ArgumentNullException("taskType");
            }

            this.taskType = taskType;
            this.buildLogger = buildLogger;

            project.AddNewUsingTaskFromAssemblyName(this.taskType.FullName, this.taskType.Assembly.FullName);
        }
Esempio n. 14
0
 public void AddNewUsingTaskFromAssemblyName()
 {
     Project p = new Project(new Engine());
     p.AddNewUsingTaskFromAssemblyName("UsingTaskName", "UsingAssemblyName");
     object o = p.EvaluatedItems; // force evaluation of imported projects.
     XmlNodeList nl = CompatibilityTestHelpers.GetNodesWithName(p.Xml, "UsingTask");
     Assertion.AssertEquals(1, nl.Count);
     Assertion.AssertEquals("UsingTaskName", nl[0].Attributes["TaskName"].Value);
     Assertion.AssertEquals("UsingAssemblyName", nl[0].Attributes["AssemblyName"].Value);
     Assertion.AssertEquals(2, nl[0].Attributes.Count); // no condition;
 }