当前位置: 首页>>代码示例>>C#>>正文


C# Framework.BuildTargetContext类代码示例

本文整理汇总了C#中Microsoft.DotNet.Cli.Build.Framework.BuildTargetContext的典型用法代码示例。如果您正苦于以下问题:C# BuildTargetContext类的具体用法?C# BuildTargetContext怎么用?C# BuildTargetContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


BuildTargetContext类属于Microsoft.DotNet.Cli.Build.Framework命名空间,在下文中一共展示了BuildTargetContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetProductMoniker

 public static string GetProductMoniker(BuildTargetContext c)
 {
     string osname = GetOSShortName();
     var arch = CurrentArchitecture.Current.ToString();
     var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
     return $"dotnet-{osname}-{arch}.{version}";
 }
开发者ID:ericstj,项目名称:cli,代码行数:7,代码来源:Monikers.cs

示例2: ReplaceProjectJson

        public static BuildTargetResult ReplaceProjectJson(BuildTargetContext c)
        {
            List<DependencyInfo> dependencyInfos = c.GetDependencyInfos();

            IEnumerable<string> projectJsonFiles = Enumerable.Union(
                Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories),
                Directory.GetFiles(Path.Combine(Dirs.RepoRoot, @"src\dotnet\commands\dotnet-new"), "project.json.template", SearchOption.AllDirectories));

            JObject projectRoot;
            foreach (string projectJsonFile in projectJsonFiles)
            {
                try
                {
                    projectRoot = ReadProject(projectJsonFile);
                }
                catch (Exception e)
                {
                    c.Warn($"Non-fatal exception occurred reading '{projectJsonFile}'. Skipping file. Exception: {e}. ");
                    continue;
                }

                bool changedAnyPackage = FindAllDependencyProperties(projectRoot)
                    .Select(dependencyProperty => ReplaceDependencyVersion(dependencyProperty, dependencyInfos))
                    .ToArray()
                    .Any(shouldWrite => shouldWrite);

                if (changedAnyPackage)
                {
                    c.Info($"Writing changes to {projectJsonFile}");
                    WriteProject(projectRoot, projectJsonFile);
                }
            }

            return c.Success();
        }
开发者ID:krwq,项目名称:cli,代码行数:35,代码来源:UpdateFilesTargets.cs

示例3: GenerateCLISdkProductArchive

        public static BuildTargetResult GenerateCLISdkProductArchive(BuildTargetContext c)
        {
            string resourcePath = Path.Combine(Dirs.RepoRoot, "packaging", "osx", "clisdk", "resources");
            string outFilePath = Path.Combine(Dirs.Packages, c.BuildContext.Get<string>("CombinedFrameworkSDKHostInstallerFile"));

            string inputDistTemplatePath = Path.Combine(
                Dirs.RepoRoot,
                "packaging",
                "osx",
                "clisdk",
                "Distribution-Template");
            string distTemplate = File.ReadAllText(inputDistTemplatePath);
            string distributionPath = Path.Combine(PkgsIntermediateDir, "CLI-SDK-Formatted-Distribution-Template.xml");
            string formattedDistContents =
                distTemplate.Replace("{SharedFxComponentId}", SharedFxComponentId)
                .Replace("{SharedHostComponentId}", SharedHostComponentId)
                .Replace("{CLISdkComponentId}", CLISdkComponentId);
            File.WriteAllText(distributionPath, formattedDistContents);

            Cmd("productbuild",
                "--version", CLISdkNugetVersion,
                "--identifier", CLISdkPkgId,
                "--package-path", PkgsIntermediateDir,
                "--resources", resourcePath,
                "--distribution", distributionPath,
                outFilePath)
            .Execute()
            .EnsureSuccessful();

            return c.Success();
        }
开发者ID:nattress,项目名称:cli,代码行数:31,代码来源:PkgTargets.cs

示例4: GenerateVersions

        public static BuildTargetResult GenerateVersions(BuildTargetContext c)
        {
            var gitResult = Cmd("git", "rev-list", "--count", "HEAD")
                .CaptureStdOut()
                .Execute();
            gitResult.EnsureSuccessful();
            var commitCount = int.Parse(gitResult.StdOut);

            gitResult = Cmd("git", "rev-parse", "HEAD")
                .CaptureStdOut()
                .Execute();
            gitResult.EnsureSuccessful();
            var commitHash = gitResult.StdOut.Trim();

            var branchInfo = ReadBranchInfo(c, Path.Combine(c.BuildContext.BuildDirectory, "branchinfo.txt"));
            var buildVersion = new BuildVersion()
            {
                Major = int.Parse(branchInfo["MAJOR_VERSION"]),
                Minor = int.Parse(branchInfo["MINOR_VERSION"]),
                Patch = int.Parse(branchInfo["PATCH_VERSION"]),
                ReleaseSuffix = branchInfo["RELEASE_SUFFIX"],
                CommitCount = commitCount
            };
            c.BuildContext["BuildVersion"] = buildVersion;
            c.BuildContext["CommitHash"] = commitHash;

            c.Info($"Building Version: {buildVersion.SimpleVersion} (NuGet Packages: {buildVersion.NuGetVersion})");
            c.Info($"From Commit: {commitHash}");

            return c.Success();
        }
开发者ID:noahfalk,项目名称:cli,代码行数:31,代码来源:PrepareTargets.cs

示例5: RestoreTestAssetProjects

        public static BuildTargetResult RestoreTestAssetProjects(BuildTargetContext c)
        {
            CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
            CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test"));

            CleanNuGetTempCache();

            var dotnet = DotNetCli.Stage2;
            dotnet.Restore(
                "--verbosity", "verbose",
                "--infer-runtimes",
                "--fallbacksource", Dirs.TestPackages)
                .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"))
                .Execute().EnsureSuccessful();

            // The 'ProjectModelServer' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output
            dotnet.Restore(
                "--verbosity", "verbose",
                "--infer-runtimes")
                .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthTestProjects"))
                .Execute();

            dotnet.Restore(
                "--verbosity", "verbose",
                "--infer-runtimes")
                .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthUpdateSearchPathSample"))
                .Execute();

            return c.Success();
        }
开发者ID:krytarowski,项目名称:cli,代码行数:30,代码来源:TestTargets.cs

示例6: GenerateSdkDeb

        public static BuildTargetResult GenerateSdkDeb(BuildTargetContext c)
        {
            var channel = c.BuildContext.Get<string>("Channel").ToLower();
            var packageName = Monikers.GetSdkDebianPackageName(c);
            var version = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
            var debFile = c.BuildContext.Get<string>("SdkInstallerFile");
            var manPagesDir = Path.Combine(Dirs.RepoRoot, "Documentation", "manpages");
            var previousVersionURL = $"https://dotnetcli.blob.core.windows.net/dotnet/{channel}/Installers/Latest/dotnet-ubuntu-x64.latest.deb";
            var sdkPublishRoot = c.BuildContext.Get<string>("CLISDKRoot");
            var sharedFxDebianPackageName = Monikers.GetDebianSharedFrameworkPackageName(c);

            var objRoot = Path.Combine(Dirs.Output, "obj", "debian", "sdk");

            if (Directory.Exists(objRoot))
            {
                Directory.Delete(objRoot, true);
            }

            Directory.CreateDirectory(objRoot);

            Cmd(Path.Combine(Dirs.RepoRoot, "scripts", "package", "package-debian.sh"),
                "-v", version, 
                "-i", sdkPublishRoot, 
                "-o", debFile, 
                "-p", packageName, 
                "-m", manPagesDir, 
                "--framework-debian-package-name", sharedFxDebianPackageName,
                "--framework-nuget-name", Monikers.SharedFrameworkName,
                "--framework-nuget-version", c.BuildContext.Get<string>("SharedFrameworkNugetVersion"),
                "--previous-version-url", previousVersionURL, 
                "--obj-root", objRoot)
                    .Execute()
                    .EnsureSuccessful();
            return c.Success();
        }
开发者ID:krytarowski,项目名称:cli,代码行数:35,代码来源:DebTargets.cs

示例7: PublishCliVersionBadge

        public static BuildTargetResult PublishCliVersionBadge(BuildTargetContext c)
        {
            var versionBadge = c.BuildContext.Get<string>("VersionBadge");
            var latestVersionBadgeBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(versionBadge)}";
            var versionBadgeBlob = $"{Channel}/Binaries/{CliNuGetVersion}/{Path.GetFileName(versionBadge)}";

            AzurePublisherTool.PublishFile(versionBadgeBlob, versionBadge);
            AzurePublisherTool.PublishFile(latestVersionBadgeBlob, versionBadge);
            return c.Success();
        }
开发者ID:krytarowski,项目名称:cli,代码行数:10,代码来源:PublishTargets.cs

示例8: InitPublish

        public static BuildTargetResult InitPublish(BuildTargetContext c)
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(Environment.GetEnvironmentVariable("CONNECTION_STRING").Trim('"'));
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
            BlobContainer = blobClient.GetContainerReference("dotnet");

            Version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
            Channel = c.BuildContext.Get<string>("Channel");
            return c.Success();
        }
开发者ID:ericstj,项目名称:cli,代码行数:10,代码来源:PublishTargets.cs

示例9: GeneratePkg

 public static BuildTargetResult GeneratePkg(BuildTargetContext c)
 {
     var version = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
     var pkg = c.BuildContext.Get<string>("InstallerFile");
     Cmd(Path.Combine(Dirs.RepoRoot, "packaging", "osx", "package-osx.sh"),
             "-v", version, "-i", Dirs.Stage2, "-o", pkg)
             .Execute()
             .EnsureSuccessful();
     return c.Success();
 }
开发者ID:ericstj,项目名称:cli,代码行数:10,代码来源:InstallerTargets.cs

示例10: PublishCompressedFile

        public static BuildTargetResult PublishCompressedFile(BuildTargetContext c)
        {
            var compressedFile = c.BuildContext.Get<string>("CompressedFile");
            var compressedFileBlob = $"{Channel}/Binaries/{Version}/{Path.GetFileName(compressedFile)}";
            var latestCompressedFile = compressedFile.Replace(Version, "latest");
            var latestCompressedFileBlob = $"{Channel}/Binaries/Latest/{Path.GetFileName(latestCompressedFile)}";

            PublishFileAzure(compressedFileBlob, compressedFile);
            PublishFileAzure(latestCompressedFileBlob, compressedFile);
            return c.Success();
        }
开发者ID:ericstj,项目名称:cli,代码行数:11,代码来源:PublishTargets.cs

示例11: PublishInstallerFile

        public static BuildTargetResult PublishInstallerFile(BuildTargetContext c)
        {
            var installerFile = c.BuildContext.Get<string>("InstallerFile");
            var installerFileBlob = $"{Channel}/Installers/{Version}/{Path.GetFileName(installerFile)}";
            var latestInstallerFile = installerFile.Replace(Version, "latest");
            var latestInstallerFileBlob = $"{Channel}/Installers/Latest/{Path.GetFileName(latestInstallerFile)}";

            PublishFileAzure(installerFileBlob, installerFile);
            PublishFileAzure(latestInstallerFileBlob, installerFile);
            return c.Success();
        }
开发者ID:ericstj,项目名称:cli,代码行数:11,代码来源:PublishTargets.cs

示例12: CompileCoreHost

        public static BuildTargetResult CompileCoreHost(BuildTargetContext c)
        {
            // Generate build files
            var cmakeOut = Path.Combine(Dirs.Corehost, "cmake");

            Rmdir(cmakeOut);
            Mkdirp(cmakeOut);

            var configuration = c.BuildContext.Get<string>("Configuration");

            // Run the build
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                // Why does Windows directly call cmake but Linux/Mac calls "build.sh" in the corehost dir?
                // See the comment in "src/corehost/build.sh" for details. It doesn't work for some reason.
                var visualStudio = IsWinx86 ? "Visual Studio 14 2015" : "Visual Studio 14 2015 Win64";
                var archMacro = IsWinx86 ? "-DCLI_CMAKE_PLATFORM_ARCH_I386=1" : "-DCLI_CMAKE_PLATFORM_ARCH_AMD64=1";
                ExecIn(cmakeOut, "cmake",
                    Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost"),
                    archMacro,
                    "-G",
                    visualStudio);

                var pf32 = RuntimeInformation.OSArchitecture == Architecture.X64 ?
                    Environment.GetEnvironmentVariable("ProgramFiles(x86)") :
                    Environment.GetEnvironmentVariable("ProgramFiles");

                if (configuration.Equals("Release"))
                {
                    // Cmake calls it "RelWithDebInfo" in the generated MSBuild
                    configuration = "RelWithDebInfo";
                }

                Exec(Path.Combine(pf32, "MSBuild", "14.0", "Bin", "MSBuild.exe"),
                    Path.Combine(cmakeOut, "ALL_BUILD.vcxproj"),
                    $"/p:Configuration={configuration}");

                // Copy the output out
                File.Copy(Path.Combine(cmakeOut, "cli", configuration, "corehost.exe"), Path.Combine(Dirs.Corehost, "corehost.exe"), overwrite: true);
                File.Copy(Path.Combine(cmakeOut, "cli", configuration, "corehost.pdb"), Path.Combine(Dirs.Corehost, "corehost.pdb"), overwrite: true);
                File.Copy(Path.Combine(cmakeOut, "cli", "dll", configuration, "hostpolicy.dll"), Path.Combine(Dirs.Corehost, "hostpolicy.dll"), overwrite: true);
                File.Copy(Path.Combine(cmakeOut, "cli", "dll", configuration, "hostpolicy.pdb"), Path.Combine(Dirs.Corehost, "hostpolicy.pdb"), overwrite: true);
            }
            else
            {
                ExecIn(cmakeOut, Path.Combine(c.BuildContext.BuildDirectory, "src", "corehost", "build.sh"));

                // Copy the output out
                File.Copy(Path.Combine(cmakeOut, "cli", "corehost"), Path.Combine(Dirs.Corehost, "corehost"), overwrite: true);
                File.Copy(Path.Combine(cmakeOut, "cli", "dll", $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), Path.Combine(Dirs.Corehost, $"{Constants.DynamicLibPrefix}hostpolicy{Constants.DynamicLibSuffix}"), overwrite: true);
            }

            return c.Success();
        }
开发者ID:ericstj,项目名称:cli,代码行数:54,代码来源:CompileTargets.cs

示例13: GenerateZip

        public static BuildTargetResult GenerateZip(BuildTargetContext c)
        {
            var zipFile = c.BuildContext.Get<string>("CompressedFile");

            if (File.Exists(zipFile))
            {
                File.Delete(zipFile);
            }

            ZipFile.CreateFromDirectory(Dirs.Stage2, zipFile, CompressionLevel.Optimal, false);
            return c.Success();
        }
开发者ID:ericstj,项目名称:cli,代码行数:12,代码来源:PackageTargets.cs

示例14: RestoreTestAssetPackages

        public static BuildTargetResult RestoreTestAssetPackages(BuildTargetContext c)
        {
            CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "src"));
            CleanBinObj(c, Path.Combine(c.BuildContext.BuildDirectory, "test"));

            CleanNuGetTempCache();

            var dotnet = DotNetCli.Stage2;
            dotnet.Restore().WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestPackages")).Execute().EnsureSuccessful();

            return c.Success();
        }
开发者ID:cdmihai,项目名称:cli,代码行数:12,代码来源:TestTargets.cs

示例15: InitPublish

        public static BuildTargetResult InitPublish(BuildTargetContext c)
        {
            AzurePublisherTool = new AzurePublisher();
            DebRepoPublisherTool = new DebRepoPublisher(Dirs.Packages);

            CliVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").SimpleVersion;
            CliNuGetVersion = c.BuildContext.Get<BuildVersion>("BuildVersion").NuGetVersion;
            SharedFrameworkNugetVersion = c.BuildContext.Get<string>("SharedFrameworkNugetVersion");
            Channel = c.BuildContext.Get<string>("Channel");

            return c.Success();
        }
开发者ID:krytarowski,项目名称:cli,代码行数:12,代码来源:PublishTargets.cs


注:本文中的Microsoft.DotNet.Cli.Build.Framework.BuildTargetContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。