Ejemplo n.º 1
0
        public static void TargetFxCop(ITaskContext context)
        {
            FullPath rootDir = new FullPath(context.Properties[BuildProps.ProductRootDir]);

            FullPath fxcopDir = rootDir
                                .CombineWith(context.Properties[BuildProps.LibDir])
                                .CombineWith(context.Properties[BuildProps.FxCopDir]);

            FullPath buildLogsPath = new FullPath(context.Properties[BuildProps.ProductRootDir])
                                     .CombineWith(context.Properties[BuildProps.BuildLogsDir]);

            RunFxCopTask task = new RunFxCopTask(
                fxcopDir.AddFileName("FxCopCmd.exe").ToString(),
                fxcopDir.AddFileName("FxCop.exe").ToString(),
                rootDir.AddFileName("{0}.FxCop", context.Properties[BuildProps.ProductId]).ToString(),
                buildLogsPath.AddFileName("{0}.FxCopReport.xml", context.Properties[BuildProps.ProductId]).ToString());

            task.Execute(context);
        }
Ejemplo n.º 2
0
        private static void TargetPackage(ITaskContext context)
        {
            FullPath packagesDir = new FullPath(context.Properties.Get(BuildProps.ProductRootDir, "."));

            packagesDir = packagesDir.CombineWith(context.Properties.Get <string>(BuildProps.BuildDir));
            FullPath     simplexPackageDir = packagesDir.CombineWith("Detergent");
            FileFullPath zipFileName       = packagesDir.AddFileName(
                "Detergent-{0}.zip",
                context.Properties.Get <Version>(BuildProps.BuildVersion));

            StandardPackageDef packageDef = new StandardPackageDef("Detergent", context);
            VSSolution         solution   = context.Properties.Get <VSSolution>(BuildProps.Solution);

            VSProjectWithFileInfo projectInfo =
                (VSProjectWithFileInfo)solution.FindProjectByName("Detergent");
            LocalPath projectOutputPath = projectInfo.GetProjectOutputPath(
                context.Properties.Get <string>(BuildProps.BuildConfiguration));
            FullPath projectTargetDir = projectInfo.ProjectDirectoryPath.CombineWith(projectOutputPath);

            packageDef.AddFolderSource(
                "bin",
                projectTargetDir,
                false);

            ICopier       copier        = new Copier(context);
            CopyProcessor copyProcessor = new CopyProcessor(
                context,
                copier,
                simplexPackageDir);

            copyProcessor
            .AddTransformation("bin", new LocalPath(string.Empty));

            IPackageDef copiedPackageDef = copyProcessor.Process(packageDef);

            Zipper       zipper       = new Zipper(context);
            ZipProcessor zipProcessor = new ZipProcessor(
                context,
                zipper,
                zipFileName,
                simplexPackageDir,
                null,
                "bin");

            zipProcessor.Process(copiedPackageDef);
        }
Ejemplo n.º 3
0
        protected override void DoExecute(ITaskContext context)
        {
            FullPath packagesDir = new FullPath(context.Properties.Get(BuildProps.ProductRootDir, "."));

            packagesDir = packagesDir.CombineWith(context.Properties.Get <string> (BuildProps.BuildDir));

            FileFullPath destNuspecFile = packagesDir.AddFileName("{0}.nuspec", packageId);

            context.WriteInfo("Preparing the {0} file", destNuspecFile);
            ReplaceTokensTask task = new ReplaceTokensTask(
                nuspecFileName,
                destNuspecFile.ToString());

            task.AddTokenValue("version", context.Properties.Get <Version> (BuildProps.BuildVersion).ToString());
            task.Execute(context);

            // package it
            context.WriteInfo("Creating a NuGet package file");
            string           nugetWorkingDir = destNuspecFile.Directory.ToString();
            NuGetCmdLineTask nugetTask       = new NuGetCmdLineTask("pack", nugetWorkingDir);

            nugetTask
            .AddArgument(destNuspecFile.FileName);

            nugetTask.AddVerbosityArgument(NuGetCmdLineTask.NuGetVerbosity.Detailed);

            if (BasePath != null)
            {
                nugetTask.AddArgument("-BasePath").AddArgument(BasePath);
            }

            nugetTask.Execute(context);

            string nupkgFileName = ConstructNupkgFileName(context);

            context.WriteInfo("NuGet package file {0} created", nupkgFileName);

            // do not push new packages from a local build
            if (context.IsInteractive && !AllowPushOnInteractiveBuild)
            {
                return;
            }

            if (apiKeyFunc == null)
            {
                throw new InvalidOperationException("NuGet API key was not provided");
            }

            string apiKey = apiKeyFunc(context);

            if (apiKey == null)
            {
                context.WriteInfo("API key function returned null, skipping pushing of the NuGet package.");
                return;
            }

            // publish the package file
            context.WriteInfo("Pushing the NuGet package to the repository");

            nugetTask = new NuGetCmdLineTask("push", nugetWorkingDir);
            nugetTask
            .AddArgument(nupkgFileName)
            .AddArgument(apiKey)
            .AddArgument("-Source").AddArgument(nuGetServerUrl)
            .AddVerbosityArgument(NuGetCmdLineTask.NuGetVerbosity.Detailed);

            nugetTask
            .Execute(context);
        }
        protected override int DoExecute(ITaskContextInternal context)
        {
            FullPath packagesDir = new FullPath(context.Properties.Get(BuildProps.ProductRootDir, "."));

            packagesDir = packagesDir.CombineWith(context.Properties.Get <string>(DotNetBuildProps.BuildDir));

            FileFullPath destNuspecFile = packagesDir.AddFileName("{0}.nuspec", _packageId);

            DoLogInfo($"Preparing the {destNuspecFile} file");

            new ReplaceTokensTask(_nuspecFileName)
            .Replace("version", context.Properties.GetBuildVersion().BuildVersionWithQuality(3))
            .UseToken("$")
            .ToDestination(destNuspecFile.ToString())
            .ExecuteVoid(context);

            // package it
            DoLogInfo("Creating a NuGet package file");
            string           nugetWorkingDir = destNuspecFile.Directory.ToString();
            NuGetCmdLineTask nugetTask       = new NuGetCmdLineTask("pack", nugetWorkingDir)
            {
                Verbosity = NuGetCmdLineTask.NuGetVerbosity.Detailed
            };

            nugetTask.WithArguments(destNuspecFile.FileName);

            if (BasePath != null)
            {
                nugetTask.WithArguments("-BasePath", BasePath);
            }

            nugetTask.ExecuteVoid(context);

            string nupkgFileName = string.Format(
                CultureInfo.InvariantCulture,
                "{0}.{1}.nupkg",
                _packageId,
                context.Properties.GetBuildVersion().BuildVersionWithQuality(3));

            DoLogInfo($"NuGet package file {nupkgFileName} created");

            // do not push new packages from a local build
            if (context.BuildServers().IsLocalBuild&& _skipPushOnLocalBuild)
            {
                context.LogInfo("pushing package on local build is disabled in build script...Skiping.");
                return(1);
            }

            if (_apiKeyFunc == null)
            {
                throw new InvalidOperationException("NuGet API key was not provided");
            }

            string apiKey = _apiKeyFunc(context);

            if (apiKey == null)
            {
                return(1);
            }

            // publish the package file
            DoLogInfo("Pushing the NuGet package to the repository");

            nugetTask = new NuGetCmdLineTask("push", nugetWorkingDir)
            {
                Verbosity = NuGetCmdLineTask.NuGetVerbosity.Detailed,
                ApiKey    = apiKey
            };

            if (_nuGetServerUrl != null)
            {
                nugetTask.WithArguments("-Source", _nuGetServerUrl);
            }

            nugetTask
            .WithArguments(nupkgFileName)
            .ExecuteVoid(context);

            return(0);
        }
Ejemplo n.º 5
0
        private static void TargetPackage(ITaskContext context)
        {
            FullPath packagesDir = new FullPath(context.Properties.Get(BuildProps.ProductRootDir, "."));
            packagesDir = packagesDir.CombineWith(context.Properties.Get<string>(BuildProps.BuildDir));
            FullPath simplexPackageDir = packagesDir.CombineWith("Detergent");
            FileFullPath zipFileName = packagesDir.AddFileName(
                "Detergent-{0}.zip",
                context.Properties.Get<Version>(BuildProps.BuildVersion));

            StandardPackageDef packageDef = new StandardPackageDef("Detergent", context);
            VSSolution solution = context.Properties.Get<VSSolution>(BuildProps.Solution);

            VSProjectWithFileInfo projectInfo =
                (VSProjectWithFileInfo)solution.FindProjectByName("Detergent");
            LocalPath projectOutputPath = projectInfo.GetProjectOutputPath(
                context.Properties.Get<string>(BuildProps.BuildConfiguration));
            FullPath projectTargetDir = projectInfo.ProjectDirectoryPath.CombineWith(projectOutputPath);
            packageDef.AddFolderSource(
                "bin",
                projectTargetDir,
                false);

            ICopier copier = new Copier(context);
            CopyProcessor copyProcessor = new CopyProcessor(
                 context,
                 copier,
                 simplexPackageDir);
            copyProcessor
                .AddTransformation("bin", new LocalPath(string.Empty));

            IPackageDef copiedPackageDef = copyProcessor.Process(packageDef);

            Zipper zipper = new Zipper(context);
            ZipProcessor zipProcessor = new ZipProcessor(
                context,
                zipper,
                zipFileName,
                simplexPackageDir,
                null,
                "bin");
            zipProcessor.Process(copiedPackageDef);
        }
Ejemplo n.º 6
0
        private static void TargetNuGet(ITaskContext context, string nugetId)
        {
            FullPath packagesDir = new FullPath(context.Properties.Get(BuildProps.ProductRootDir, "."));
            packagesDir = packagesDir.CombineWith(context.Properties.Get<string>(BuildProps.BuildDir));

            string sourceNuspecFile = string.Format(
                CultureInfo.InvariantCulture,
                @"{0}\{0}.nuspec",
                nugetId);
            FileFullPath destNuspecFile = packagesDir.AddFileName("{0}.nuspec", nugetId);

            context.WriteInfo("Preparing the {0} file", destNuspecFile);
            ExpandPropertiesTask task = new ExpandPropertiesTask(
                sourceNuspecFile,
                destNuspecFile.ToString(),
                Encoding.UTF8,
                Encoding.UTF8);
            task.AddPropertyToExpand("version", context.Properties.Get<Version>(BuildProps.BuildVersion).ToString());
            task.Execute(context);

            // package it
            context.WriteInfo("Creating a NuGet package file");
            RunProgramTask progTask = new RunProgramTask(@"lib\NuGet\NuGet.exe");
            progTask.SetWorkingDir(destNuspecFile.Directory.ToString());
            progTask
                .AddArgument("pack")
                .AddArgument(destNuspecFile.FileName)
                .AddArgument("-Verbose")
                .Execute(context);

            string nupkgFileName = string.Format(
                CultureInfo.InvariantCulture,
                "{0}.{1}.nupkg",
                nugetId,
                context.Properties.Get<Version>(BuildProps.BuildVersion));
            context.WriteInfo("NuGet package file {0} created", nupkgFileName);

            string apiKeyFileName = "NuGet API key.txt";
            if (!File.Exists(apiKeyFileName))
            {
                context.WriteInfo("'NuGet API key.txt' does not exist, cannot publish the package.");
                return;
            }

            string apiKey = File.ReadAllText(apiKeyFileName);

            // publish the package file
            context.WriteInfo("Pushing the NuGet package to the repository");

            progTask = new RunProgramTask(@"lib\NuGet\NuGet.exe");
            progTask.SetWorkingDir(destNuspecFile.Directory.ToString());
            progTask
                .AddArgument("push")
                .AddArgument(nupkgFileName)
                .AddArgument(apiKey)
                .AddArgument("-Source")
                .AddArgument("http://packages.nuget.org/v1/")
                .Execute(context);
        }
Ejemplo n.º 7
0
        private static void TargetNuGet(ITaskContext context, string nugetId)
        {
            FullPath packagesDir = new FullPath(context.Properties.Get(BuildProps.ProductRootDir, "."));

            packagesDir = packagesDir.CombineWith(context.Properties.Get <string>(BuildProps.BuildDir));

            string sourceNuspecFile = string.Format(
                CultureInfo.InvariantCulture,
                @"{0}\{0}.nuspec",
                nugetId);
            FileFullPath destNuspecFile = packagesDir.AddFileName("{0}.nuspec", nugetId);

            context.WriteInfo("Preparing the {0} file", destNuspecFile);
            ExpandPropertiesTask task = new ExpandPropertiesTask(
                sourceNuspecFile,
                destNuspecFile.ToString(),
                Encoding.UTF8,
                Encoding.UTF8);

            task.AddPropertyToExpand("version", context.Properties.Get <Version>(BuildProps.BuildVersion).ToString());
            task.Execute(context);

            // package it
            context.WriteInfo("Creating a NuGet package file");
            RunProgramTask progTask = new RunProgramTask(@"lib\NuGet\NuGet.exe");

            progTask.SetWorkingDir(destNuspecFile.Directory.ToString());
            progTask
            .AddArgument("pack")
            .AddArgument(destNuspecFile.FileName)
            .AddArgument("-Verbose")
            .Execute(context);

            string nupkgFileName = string.Format(
                CultureInfo.InvariantCulture,
                "{0}.{1}.nupkg",
                nugetId,
                context.Properties.Get <Version>(BuildProps.BuildVersion));

            context.WriteInfo("NuGet package file {0} created", nupkgFileName);

            string apiKeyFileName = "NuGet API key.txt";

            if (!File.Exists(apiKeyFileName))
            {
                context.WriteInfo("'NuGet API key.txt' does not exist, cannot publish the package.");
                return;
            }

            string apiKey = File.ReadAllText(apiKeyFileName);

            // publish the package file
            context.WriteInfo("Pushing the NuGet package to the repository");

            progTask = new RunProgramTask(@"lib\NuGet\NuGet.exe");
            progTask.SetWorkingDir(destNuspecFile.Directory.ToString());
            progTask
            .AddArgument("push")
            .AddArgument(nupkgFileName)
            .AddArgument(apiKey)
            .AddArgument("-Source")
            .AddArgument("http://packages.nuget.org/v1/")
            .Execute(context);
        }