Ejemplo n.º 1
0
        /// <summary>
        /// Gets the solution path by using the IdeConfiguration
        /// </summary>
        public static AbsolutePath GetSolutionPath(IIdeConfiguration configuration, PathTable pathTable)
        {
            var solutionName        = configuration.SolutionName;
            var solutionNameWithExt = solutionName.Concat(pathTable.StringTable, PathAtom.Create(pathTable.StringTable, ".sln"));

            // $SolutionRoot$\$SolutionName$\$SolutionName$.sln
            return(configuration.SolutionRoot.Combine(pathTable, solutionName, solutionNameWithExt));
        }
Ejemplo n.º 2
0
        public Context(
            PipExecutionContext pipContext,
            PipGraph pipGraph,
            IReadonlyDirectedGraph scheduledGraph,
            AbsolutePath configFilePath,
            IIdeConfiguration ideConfig)
        {
            Contract.Requires(pipGraph != null);
            Contract.Requires(scheduledGraph != null);
            Contract.Requires(configFilePath.IsValid);
            Contract.Requires(ideConfig.SolutionRoot.IsValid);
            Contract.Requires(ideConfig.SolutionName.IsValid);
            Contract.Requires(ideConfig.IsEnabled);
            Contract.Requires(ideConfig.IsNewEnabled);

            PipGraph       = pipGraph;
            ScheduledGraph = scheduledGraph;
            StringTable    = pipContext.StringTable;
            PathTable      = pipContext.PathTable;
            SymbolTable    = pipContext.SymbolTable;
            QualifierTable = pipContext.QualifierTable;
            IdeConfig      = ideConfig;

            DotSettingsPathStr = ideConfig.DotSettingsFile.IsValid ? ideConfig.DotSettingsFile.ToString(PathTable) : null;
            ConfigFilePathStr  = configFilePath.ToString(PathTable);

            EnlistmentRoot    = configFilePath.GetParent(PathTable);
            EnlistmentRootStr = EnlistmentRoot.ToString(PathTable);

            SolutionRoot    = ideConfig.SolutionRoot;
            SolutionRootStr = SolutionRoot.ToString(PathTable);

            SolutionFilePathStr = IdeGenerator.GetSolutionPath(ideConfig, PathTable).ToString(PathTable);

            CanWriteToSrc = ideConfig.CanWriteToSrc ?? false;
            ProjectsRoot  = CanWriteToSrc
                    ? EnlistmentRoot
                    : SolutionRoot.Combine(PathTable, PathAtom.Create(PathTable.StringTable, "Projects"));

            ResxExtensionName      = PathAtom.Create(StringTable, ".resx");
            CscExeName             = PathAtom.Create(StringTable, "csc.exe");
            CscDllName             = PathAtom.Create(StringTable, "csc.dll");
            XunitConsoleDllName    = PathAtom.Create(StringTable, "xunit.console.dll");
            XunitConsoleExeName    = PathAtom.Create(StringTable, "xunit.console.exe");
            QtestExeName           = PathAtom.Create(StringTable, "DBS.QTest.exe");
            DotnetName             = PathAtom.Create(StringTable, "dotnet");
            DotnetExeName          = PathAtom.Create(StringTable, "dotnet.exe");
            ResgenExeName          = PathAtom.Create(StringTable, "ResGen.exe");
            ResourcesExtensionName = PathAtom.Create(StringTable, ".resources");
            CsExtensionName        = PathAtom.Create(StringTable, ".cs");
            DllExtensionName       = PathAtom.Create(StringTable, ".dll");
            ClExeName             = PathAtom.Create(StringTable, "cl.exe");
            LinkExeName           = PathAtom.Create(StringTable, "Link.exe");
            VsTestExeName         = PathAtom.Create(StringTable, "vstest.console.exe");
            AssemblyDeploymentTag = StringId.Create(StringTable, "assemblyDeployment");
            TestDeploymentTag     = StringId.Create(StringTable, "testDeployment");
        }
Ejemplo n.º 3
0
        /// <nodoc />
        public IdeConfiguration(IIdeConfiguration template, PathRemapper pathRemapper)
        {
            Contract.Assume(template != null);

            IsEnabled       = template.IsEnabled;
            CanWriteToSrc   = template.CanWriteToSrc;
            SolutionName    = pathRemapper.Remap(template.SolutionName);
            SolutionRoot    = pathRemapper.Remap(template.SolutionRoot);
            DotSettingsFile = pathRemapper.Remap(template.DotSettingsFile);
        }
Ejemplo n.º 4
0
        /// <nodoc />
        public IdeConfiguration(IIdeConfiguration template, PathRemapper pathRemapper)
        {
            Contract.Assume(template != null);

            IsEnabled        = template.IsEnabled;
            IsNewEnabled     = template.IsNewEnabled;
            CanWriteToSrc    = template.CanWriteToSrc;
            SolutionName     = pathRemapper.Remap(template.SolutionName);
            SolutionRoot     = pathRemapper.Remap(template.SolutionRoot);
            DotSettingsFile  = pathRemapper.Remap(template.DotSettingsFile);
            TargetFrameworks = new List <string>(template.TargetFrameworks);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructs an Ide Generator from the BuildXL.Execution.Analyzer
 /// </summary>
 public IdeGenerator(PipExecutionContext pipContext, PipGraph pipGraph, IReadonlyDirectedGraph scheduledGraph, AbsolutePath configFilePath, IIdeConfiguration ideConfig)
 {
     m_context = new Context(pipContext, pipGraph, scheduledGraph, configFilePath, ideConfig);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Constructs an Ide Generator and generates the files
        /// </summary>
        public static bool Generate(PipExecutionContext pipContext, PipGraph pipGraph, IReadonlyDirectedGraph scheduledGraph, AbsolutePath configFilePath, IIdeConfiguration ideConfig)
        {
            var generator = new IdeGenerator(pipContext, pipGraph, scheduledGraph, configFilePath, ideConfig);

            return(generator.Generate());
        }
Ejemplo n.º 7
0
        public static void WriteCmd(string commandLine, IIdeConfiguration config, AbsolutePath configFile, PathTable pathTable, [CanBeNull] PathTranslator translator)
        {
            var enlistmentRoot = configFile.GetParent(pathTable).ToString(pathTable);

            var builder = new StringBuilder();

            builder.AppendLine("@echo off");

            if (translator == null)
            {
                builder.AppendLine("cd " + enlistmentRoot);
            }
            else
            {
                enlistmentRoot = translator.Translate(enlistmentRoot);
            }

            // Remove trailing file path separators.
            enlistmentRoot = enlistmentRoot.TrimEnd('\\');

            foreach (DictionaryEntry envVar in Environment.GetEnvironmentVariables())
            {
                var key   = (string)envVar.Key;
                var value = (string)envVar.Value;

                // If the value contains '<' or '>', add escape character; otherwise we will see syntax error when running build.cmd.
                value = Regex.Replace(value, @"[<>]", m => $"^{m.Value}");

                // Scrub newlines and tabs as they will break the generated build.cmd
                value = Regex.Replace(value, @"[\r,\n,\t]", m => " ");

                builder.AppendLine("Set " + key + "=" + value);
            }

            commandLine = FixCommandLine(commandLine);

            // Prepend to the command line the RunInSubst executable and its parameters
            int    exeIndex = commandLine.IndexOf($"\\{Branding.ProductExecutableName}", StringComparison.OrdinalIgnoreCase);
            string binRoot  = exeIndex > -1
                ? commandLine.Substring(0, exeIndex)
                : Path.GetDirectoryName(AssemblyHelper.GetAssemblyLocation(System.Reflection.Assembly.GetEntryAssembly()));

            if (translator != null)
            {
                binRoot = translator.Translate(binRoot);
            }

            string substedCommandLine = I($@"""{binRoot}\RunInSubst.exe"" B={enlistmentRoot} {commandLine} /server+ @%~dp0\build.cmd.rsp @%~dp0\domino.cmd.rsp %*"); // Also add the legacy response file domino.rsp for old plugins

            builder.AppendLine(substedCommandLine);
            builder.AppendLine("set RETURN_CODE=%ERRORLEVEL%");

            // Map the drive back.
            // RunInSubst is unmapping the drive to follow WDG protocol, but to run unit tests we need the drive still mapped.
            builder.AppendLine(string.Format(CultureInfo.InvariantCulture, "subst B: {0}", enlistmentRoot));

            // Return the exit code of BuildXL.
            builder.AppendLine("exit /b %RETURN_CODE%");
            builder.AppendLine();

            var solutionDirPath = GetSolutionPath(config, pathTable).GetParent(pathTable).ToString(pathTable);

            File.WriteAllText(Path.Combine(solutionDirPath, "build.cmd.rsp"), string.Empty);
            File.WriteAllText(Path.Combine(solutionDirPath, "build.cmd"), builder.ToString());

            // Legacy file to support old plugins
            File.WriteAllText(Path.Combine(solutionDirPath, "domino.cmd"), "@call %~dp0build.cmd %*");
            File.WriteAllText(Path.Combine(solutionDirPath, "domino.cmd.rsp"), string.Empty); // Legacy response file for old plugin
        }