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

[ISSUE]: /updateprojectfiles fails silently depending on contents of the .csproj file #4242

Open
2 tasks done
aidanblacklumeris opened this issue Oct 2, 2024 · 1 comment

Comments

@aidanblacklumeris
Copy link

Prerequisites

  • I have written a descriptive issue title
  • I have searched issues to ensure it has not already been reported

GitVersion package

GitVersion.Tool

GitVersion version

5.12.0+Branch.support-5.x.Sha.3f75764963eb3d7956dcd5a40488c074dd9faf9e

Operating system

Windows

What are you seeing?

I added a pre-build event to update the project files on a new C# project using the /updateprojectfiles flag. On build, GitVersion was running and outputting json to the console, but the .csproj files were not getting modified. Adding -diag or /verbosity Diagnostic did not give any additional output other than the json containing the generated variables. When I compared the project file to one that was working, it had some additional elements, so I removed those and re-ordered the remaining ones to match. This fixed the issue and the files are now updating correctly. Additionally, the -diag option is now working as expected, but /verbosity Diagnostic still gives no additional output.

What is expected?

If there is a problem with the project file, GitVersion should output an error message.

Steps to Reproduce

Original .csproj (partial):

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <OutputType>Exe</OutputType>
    <StartupObject>AppName.Program</StartupObject>
    <AssemblyTitle>AppName</AssemblyTitle>
    <Product>AppName</Product>
    <Copyright>Copyright © 2024</Copyright>
    <Version>2.0.0.0</Version>
    <GenerateAssemblyInfo>False</GenerateAssemblyInfo>
    <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
    <AssemblyName>AppName</AssemblyName>
    <RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>disable</Nullable>
    <GenerateDocumentationFile>True</GenerateDocumentationFile>
    <DocumentationFile>./AppName.xml</DocumentationFile>
    <DefaultDocumentationGeneratedPages>Namespaces,Types</DefaultDocumentationGeneratedPages>
    <PublishTrimmed>False</PublishTrimmed>
    <PublishAot>False</PublishAot>
    <Authors>Authors</Authors>
    <Company>Company</Company>
  </PropertyGroup>

Modified .csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <Authors>Authors</Authors>
    <Company>Company</Company>
    <Copyright>Copyright © 2024</Copyright>
    <Product>AppName</Product>
    <AssemblyName>$(MSBuildProjectName)</AssemblyName>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>disable</Nullable>
    <Version>2.0.3-branchname-0029</Version>
    <AssemblyVersion>2.0.3.0</AssemblyVersion>
    <FileVersion>2.0.3.0</FileVersion>
    <InformationalVersion>2.0.3-branchname.29+Branch.branchname.Sha.xxxxx</InformationalVersion>
  </PropertyGroup>
  <PropertyGroup>
    <RootNamespace>$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
    <DocumentationFile>./AppName.xml</DocumentationFile>
    <DefaultDocumentationGeneratedPages>Namespaces,Types</DefaultDocumentationGeneratedPages>
  </PropertyGroup>

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

No messages were received
@aidanblacklumeris
Copy link
Author

aidanblacklumeris commented Oct 2, 2024

On further investigation, the problem appears to be due to the <GenerateAssemblyInfo>False</GenerateAssemblyInfo> element. While I can understand this, it was not obvious initially from the GitVersion Command Line docs, and since the MSBuild documentation centers around using the package attributes to generate the AssemblyInfo.cs file. Perhaps a warning would be appropriate when this setting conflicts with the /updateprojectfiles flag?

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

No branches or pull requests

1 participant