Пример #1
0
        public TRunner ExpandProperties(
            string sourceFileName,
            string expandedFileName,
            Encoding sourceFileEncoding,
            Encoding expandedFileEncoding,
            IDictionary <string, string> properties)
        {
            ExpandPropertiesTask task = new ExpandPropertiesTask(
                sourceFileName,
                expandedFileName,
                sourceFileEncoding,
                expandedFileEncoding);

            foreach (KeyValuePair <string, string> pair in properties)
            {
                task.AddPropertyToExpand(pair.Key, pair.Value);
            }

            return(RunTask(task));
        }
Пример #2
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);
        }
Пример #3
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);
        }