示例#1
0
        public BuildContext(BuildCommand command)
        {
            Command     = command;
            Bazel       = new BazelContext(command);
            NuGetConfig = ToolPath(command.nuget_config);
            Tfm         = command.tfm;
            MSBuild     = new MSBuildContext(
                command,
                Bazel,
                NuGetConfig,
                ToolPath(command.directory_bazel_props)
                );

            IsExecutable = command.output_type == "exe";

            SdkRoot = ToolPath(command.sdk_root);

            ProjectFile      = ExecPath(command.project_file);
            ProjectDirectory = Path.GetDirectoryName(ProjectFile) !;

            IsTest = !string.IsNullOrEmpty(command.is_test);

            ProjectBazelProps = new Dictionary <string, string>()
            {
                ["Workspace"] = Bazel.Label.Workspace
            };

            void TrySetProp(string?value, string name)
            {
                value = value?.Trim('\'', '"');
                if (!string.IsNullOrEmpty(value))
                {
                    ProjectBazelProps ![name] = value;
                }
示例#2
0
        public MSBuildContext(BuildCommand command,
                              BazelContext bazel,
                              string nuGetConfig,
                              string directoryBazelPropsPath)
        {
            Configuration = command.configuration;
            OutputPath    = bazel.OutputDir;
            PublishDir    = Path.Combine(OutputPath, "publish", command.tfm);
            BaseIntermediateOutputPath = Path.Combine(OutputPath, "restore", "_");

            IntermediateOutputPath = Path.Combine(OutputPath, "obj");

            var propsDirectory = Path.GetDirectoryName(directoryBazelPropsPath);

            var
                noWarn = "NU1603"; // Microsoft.TestPlatform.TestHost 16.7.1 depends on Newtonsoft.Json (>= 9.0.1) but Newtonsoft.Json 9.0.1 was not found. An approximate best match of Newtonsoft.Json 13.0.1 was resolved.

            GlobalProperties = new Dictionary <string, string>
            {
                ["Configuration"]          = Configuration,
                ["BuildProjectReferences"] = "false",
                // enables a faster nuget restore compatible with isolated builds
                // https://github.com/NuGet/NuGet.Client/blob/21e2a87537cd9655b7f6599af013d447aa058e29/src/NuGet.Core/NuGet.Build.Tasks/NuGet.targets#L1310
                ["RestoreUseStaticGraphEvaluation"] = "true",
                ["RestoreRecursive"] = "false", // only restore the entry project, not referenced projects
            };

            switch (Configuration.ToLower())
            {
            case "debug":
                GlobalProperties["DebugSymbols"] = "true";
                break;

            case "release":
            case "fastbuild":
                GlobalProperties["DebugSymbols"] = "false";
                GlobalProperties["DebugType"]    = "none";
                break;
            }

            BuildEnvironment = new Dictionary <string, string>()
            {