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

Multiple AssemblyInfo should be OK #263

Open
jzabroski opened this issue Sep 17, 2019 · 9 comments
Open

Multiple AssemblyInfo should be OK #263

jzabroski opened this issue Sep 17, 2019 · 9 comments

Comments

@jzabroski
Copy link

What exactly are you trying to guard against here?

In my use case, I have a Linked GlobalAssemblyInfo.cs which contains things like AssemblyCopyright, AssemblyTrademark, AssemblyVersion, AssemblyFileVersion, AssemblyInformationalVersion, AssemblyCulture, AssemblyDescription, etc.

The only things I have in my "normal" AssemblyInfo is AssemblyTitleAttribute, ComVisibleAttribute, and GuidAttribute.

if (assemblyInfoAllFiles.Count > 1)
{
var fileList = string.Join(", ", assemblyInfoAllFiles.Select(x => rootDirectory.GetRelativePathTo(x)));
this.logger.LogWarning(
$@"Could not read assembly information, multiple files found:{Environment.NewLine}{fileList}");
project.HasMultipleAssemblyInfoFiles = true;
return null;
}

@jzabroski
Copy link
Author

This functionality also doesn't work right.

My newly generated dotnet SDK project file generates a <ApplicationVersion>1.0.0.0</ApplicationVersion> despite also having <GenerateAssemblyInfo>false</GenerateAssemblyInfo>

I think if you disable GenerateAssemblyInfo, you shouldnt automatically choose ApplicationVersion.

@jzabroski
Copy link
Author

jzabroski commented Sep 17, 2019

In general, I think this feature more or less works "correctly" (if in a hacky way), in the sense that if you DO have more than one AssemblyInfo file, chances are you are doing what I am doing. The only escaped defect is introducing ApplicationVersion element.

Would it be possible to use Roslyn to load all AssemblyInfo files and make sure they're mutually exclusive?

I'm just not sure why you would drop out if you encountered more than one file.

@andrew-boyarshin
Copy link
Collaborator

#257 (comment)

And regarding the ApplicationVersion — I'll look into it.

@andrew-boyarshin
Copy link
Collaborator

andrew-boyarshin commented Sep 18, 2019

@jzabroski ApplicationVersion is not related to AssemblyInfo files in CPS (although, of course, it can be specified in such files). The behaviour is intended, no bug here, although it can be a feature request: simplify away this property if default value of 1.0.0.0 is specified (and its variations, like 1.0). This issue is to be closed and a new one opened for feature request, unless, of course, I've got your comments wrong.

For future reference:
The full list of automatically-generated AssemblyInfo properties:

AssemblyCompany
AssemblyConfiguration
AssemblyCopyright
AssemblyDescription
AssemblyFileVersion
AssemblyInformationalVersion
AssemblyProduct
AssemblyTitle
AssemblyVersion
NeutralResourcesLanguage

@jzabroski
Copy link
Author

I think you got it wrong.

ApplicationVersion is a SemVer helper and orthogonal to Assembly Info for GREENFIELD projects.

For existing projects, I think Assembly Version Info is correct

@andrew-boyarshin
Copy link
Collaborator

andrew-boyarshin commented Sep 18, 2019

@jzabroski sorry, I still don't follow.

My newly generated dotnet SDK project file generates a <ApplicationVersion>1.0.0.0</ApplicationVersion> despite also having <GenerateAssemblyInfo>false</GenerateAssemblyInfo>

Generated by whom? .NET Core SDK CLI (dotnet new) or dotnet-migrate-201X?

ApplicationVersion is a SemVer helper and orthogonal to Assembly Info for GREENFIELD projects.

I assume GREENFIELD is some non-open-source project/organization/company?
Well, .NET Core SDK 5.0 (nightly) only has one mention of that property in the feature sector I'm not well informed of.

And I'm still not sure what exactly the issue is with ApplicationVersion property. Why are you mentioning AssemblyInfo files while they are orthogonal to the property in question?

@jzabroski
Copy link
Author

Sorry, I was not clear. Hope you can forgive me. Take 2:

Greenfield is a term for building brand new projects (e.g., dotnet new).

Brownfield is a term for maintaining and upgrading existing projects (dotnet-migrate201x helps with this).

For an application that is on Version 2.0, it makes little sense for the output to generate <ApplicationVersion>1.0.0.0</ApplicationVerison>

I think, if you're manually moving from MSBuild file format to .NET Core Common Project System format, then you're safest bet is to either omit ApplicationVersion or use AssemblyVersionAttribute metadata (especially in the case of an executable target vs. a library).

I don't think dotnet-migrate-201x should just throw in ApplicationVersion because that's what dotnet new does. Do you agree or disagree?

@mungojam
Copy link
Collaborator

mungojam commented Sep 18, 2019 via email

@jzabroski
Copy link
Author

So, I searched GitHub to see how people might use my concept of GlobalAssemblyInfo (because I learned it from other developers and assume such practices spread like a virus/meme). See here: https://github.com/search?p=4&q=globalassemblyinfo&type=Code

It's interesting that a large number of projects put their "Global Assembly Info" data in a special static class and then reference it in their AssemblyInfo.cs. I don't think this approach is as good as mine because there is overhead associated with loading the second assembly, just for the sake of loading assembly metadata. In this scenario, @mungojam 's logic doesn't work, either, though. The irony is that a meta-circular upgrade test would have the same problem: This csproj project has AssemblyInfoReader.cs and AssemblyInfo.cs

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

No branches or pull requests

3 participants