Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitVersionTaskAssemblyInfo.g.cs Namespace GitVersionTask #540

Closed
jonathannaim opened this issue Jul 28, 2015 · 11 comments · Fixed by #574
Closed

GitVersionTaskAssemblyInfo.g.cs Namespace GitVersionTask #540

jonathannaim opened this issue Jul 28, 2015 · 11 comments · Fixed by #574

Comments

@jonathannaim
Copy link

Hello,

I've just upgraded to version 3.0.

Having each GitVersionTaskAssemblyInfo in the default assembly is very nice for us as some of our assemblies are using InternalsVisibleTo

I'm unsure why but during some Rebuild All the namespace generated is completely random and causes a compilation error but if you build again then the issue is fixed and the correct namespace appears

Are you facing the same issue?

Example of a generated namespace:

//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     GitVersion
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: AssemblyVersion("0.3.0.0")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0-unstable.690+Branch.develop.Sha.b9d132f75f2667e0ea38ec52dd6e7a2a1b1b7004")]

namespace 1agvoemt
{

    [System.Runtime.CompilerServices.CompilerGenerated]
    static class GitVersionInformation
    {
        public static string Major = "0";
        public static string Minor = "3";
        public static string Patch = "0";
        public static string PreReleaseTag = "unstable.690";
        public static string PreReleaseTagWithDash = "-unstable.690";
        public static string BuildMetaData = "690";
        public static string FullBuildMetaData = "690.Branch.develop.Sha.b9d132f75f2667e0ea38ec52dd6e7a2a1b1b7004";
        public static string MajorMinorPatch = "0.3.0";
        public static string SemVer = "0.3.0-unstable.690";
        public static string LegacySemVer = "0.3.0-unstable690";
        public static string LegacySemVerPadded = "0.3.0-unstable0690";
        public static string AssemblySemVer = "0.3.0.0";
        public static string FullSemVer = "0.3.0-unstable.690";
        public static string InformationalVersion = "0.3.0-unstable.690+Branch.develop.Sha.b9d132f75f2667e0ea38ec52dd6e7a2a1b1b7004";
        public static string BranchName = "develop";
        public static string Sha = "b9d132f75f2667e0ea38ec52dd6e7a2a1b1b7004";
        public static string NuGetVersionV2 = "0.3.0-unstable0690";
        public static string NuGetVersion = "0.3.0-unstable0690";
        public static string CommitDate = "2015-07-28";
    }

}
@JakeGinnivan
Copy link
Contributor

Hrrm not sure, have not seen this before. The code which gets the namespace is https://github.com/GitTools/GitVersion/blob/master/src/GitVersionTask/AssemblyInfoBuilder/UpdateAssemblyInfo.cs#L94

@SimonCropp / @distantcam any thoughts?

@distantcam
Copy link
Contributor

@jonathannaim Is this in an ASP.NET project?

@jonathannaim
Copy link
Author

no. It's a C# WPF solution with several projects.

@distantcam
Copy link
Contributor

@jonathannaim Hmm. Can you provide a project that has the issue?

@jonathannaim
Copy link
Author

@distantcam unlikely unfortunately. The repo is is private

I'm happy to try to investigate but unsure where to start.

@jonathannaim
Copy link
Author

@distantcam . Quick update, I had a quick look.

To generate the namespace you are taking the name of the project without the extension and it looks like that in some scenario msbuild uses a temp name during the build (I'm unsure why yet)

see below:

    43>UpdateAssemblyInfo:
         INFO [07/28/15 9:21:47:09] Version not in cache. Calculating version.
         INFO [07/28/15 9:21:47:09] Project root is: C:\a\src
         INFO [07/28/15 9:21:47:10] Using latest commit on specified branch
         INFO [07/28/15 9:21:47:10] Running against branch: develop (b9d132f75f2667e0ea38ec52dd6e7a2a1b1b7004)
    42>obj\Debug\GitVersionTaskAssemblyInfo.g.cs(18,11): error CS1001: Identifier expected [C:\a\src\SolutionDir\Project.Harness\1gd4yfjc.tmp_proj]
    42>obj\Debug\GitVersionTaskAssemblyInfo.g.cs(18,12): error CS0116: A namespace cannot directly contain members such as fields or methods [C:\a\src\SolutionDir\Project.Harness\1gd4yfjc.tmp_proj]
    42>obj\Debug\GitVersionTaskAssemblyInfo.g.cs(18,11): error CS1514: { expected [C:\a\src\SolutionDir\Project.Harness\1gd4yfjc.tmp_proj]
    42>obj\Debug\GitVersionTaskAssemblyInfo.g.cs(19,1): error CS1022: Type or namespace definition, or end-of-file expected [C:\a\src\SolutionDir\Project.Harness\1gd4yfjc.tmp_proj]

@jonathannaim
Copy link
Author

@distantcam here is the answer to why sometimes the project name is the original one or a temporary one

Let me know if you need extra info

link to stackoverflow

@hazzik
Copy link

hazzik commented Jul 30, 2015

I think there are two options to fix this issue:

  • either put GitVersionInformation to the root empty namespace, or
  • use $(RootNamespace) MSBuild variable.

@JakeGinnivan
Copy link
Contributor

either put GitVersionInformation to the root empty namespace, or

We changed this intentionally because it causes compile errors when you use InternalsVisibleTo

@hazzik
Copy link

hazzik commented Jul 30, 2015

@JakeGinnivan so, then the only option is to use $(RootNamespace) from the project file, otherwise fallback to Path.GetFileNameWithoutExtension(ProjectFile) if $(RootNamespace) is not set.

@hazzik
Copy link

hazzik commented Aug 16, 2015 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants