GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

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

Open aidanblacklumeris opened this issue 1 year ago • 1 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] 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 avatar Oct 02 '24 17:10 aidanblacklumeris