public void WixVersionFileContentTest()
        {
            using (var fixture = new EmptyRepositoryFixture())
            {
                fixture.MakeATaggedCommit("1.2.3");
                fixture.MakeACommit();

                var gitVersionExecutionResults = GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: null);
                VersionVariables vars          = gitVersionExecutionResults.OutputVariables;

                GitVersionHelper.ExecuteIn(fixture.RepositoryPath, arguments: " -updatewixversionfile");

                var gitVersionVarsInWix = GetGitVersionVarsInWixFile(Path.Combine(fixture.RepositoryPath, WixVersionFileName));
                var gitVersionVars      = VersionVariables.AvailableVariables;

                foreach (var variable in gitVersionVars)
                {
                    string value;
                    vars.TryGetValue(variable, out value);
                    //Make sure the variable is present in the Wix file
                    Assert.IsTrue(gitVersionVarsInWix.ContainsKey(variable));
                    //Make sure the values are equal
                    Assert.AreEqual(value, gitVersionVarsInWix[variable]);
                }
            }
        }
        public void Execute(VersionVariables variables, OutputContext context)
        {
            var gitVersionOptions = options.Value;

            if (gitVersionOptions.Output.Contains(OutputType.BuildServer))
            {
                buildAgent?.WriteIntegration(console.WriteLine, variables);
            }
            if (gitVersionOptions.Output.Contains(OutputType.Json))
            {
                switch (gitVersionOptions.ShowVariable)
                {
                case null:
                    console.WriteLine(variables.ToString());
                    break;

                default:
                    if (!variables.TryGetValue(gitVersionOptions.ShowVariable, out var part))
                    {
                        throw new WarningException($"'{gitVersionOptions.ShowVariable}' variable does not exist");
                    }

                    console.WriteLine(part);
                    break;
                }
            }
        }
示例#3
0
    public void Execute(VersionVariables variables, OutputContext context)
    {
        var gitVersionOptions = this.options.Value;

        if (gitVersionOptions.Output.Contains(OutputType.BuildServer))
        {
            this.buildAgent.WriteIntegration(this.console.WriteLine, variables, context.UpdateBuildNumber ?? true);
        }
        if (gitVersionOptions.Output.Contains(OutputType.File))
        {
            var retryOperation = new RetryAction <IOException>();
            retryOperation.Execute(() => this.fileSystem.WriteAllText(context.OutputFile, variables.ToString()));
        }

        if (!gitVersionOptions.Output.Contains(OutputType.Json))
        {
            return;
        }

        switch (gitVersionOptions.ShowVariable)
        {
        case null:
            this.console.WriteLine(variables.ToString());
            break;

        default:
            if (!variables.TryGetValue(gitVersionOptions.ShowVariable, out var part))
            {
                throw new WarningException($"'{gitVersionOptions.ShowVariable}' variable does not exist");
            }

            this.console.WriteLine(part);
            break;
        }
    }
示例#4
0
        public void Execute(VersionVariables variables, OutputContext context)
        {
            var gitVersionOptions = options.Value;

            if (gitVersionOptions.Output.Contains(OutputType.BuildServer))
            {
                buildAgent?.WriteIntegration(console.WriteLine, variables, context.UpdateBuildNumber ?? true);
            }
            if (gitVersionOptions.Output.Contains(OutputType.File))
            {
                var retryOperation = new OperationWithExponentialBackoff <IOException>(new ThreadSleep(), log, () => fileSystem.WriteAllText(context.OutputFile, variables.ToString()));
                retryOperation.ExecuteAsync().Wait();
            }
            if (gitVersionOptions.Output.Contains(OutputType.Json))
            {
                switch (gitVersionOptions.ShowVariable)
                {
                case null:
                    console.WriteLine(variables.ToString());
                    break;

                default:
                    if (!variables.TryGetValue(gitVersionOptions.ShowVariable, out var part))
                    {
                        throw new WarningException($"'{gitVersionOptions.ShowVariable}' variable does not exist");
                    }

                    console.WriteLine(part);
                    break;
                }
            }
        }
示例#5
0
    private static string GetWixFormatFromVersionVariables(VersionVariables variables)
    {
        var builder = new StringBuilder();

        builder.Append("<Include xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\n");
        var availableVariables = VersionVariables.AvailableVariables;

        foreach (var variable in availableVariables)
        {
            variables.TryGetValue(variable, out var value);
            builder.Append($"\t<?define {variable}=\"{value}\"?>\n");
        }
        builder.Append("</Include>\n");
        return(builder.ToString());
    }