Skip to content

Commit

Permalink
Update GetFileVersionInfo to find exe file.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed May 13, 2024
1 parent d73741d commit 03c2dc6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.8.1] / 2023-05-13
### Updated
- Update `GetFileVersionInfo` to find `exe` file.

## [1.8.0] / 2023-03-11
### Updated
- Update `Nuke.Common` Version = `8.0.0`
Expand Down Expand Up @@ -342,6 +346,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- First Release

[vNext]: ../../compare/1.0.0...HEAD
[1.8.1]: ../../compare/1.8.0...1.8.1
[1.8.0]: ../../compare/1.7.4...1.8.0
[1.7.4]: ../../compare/1.7.3...1.7.4
[1.7.3]: ../../compare/1.7.2...1.7.3
Expand Down
11 changes: 6 additions & 5 deletions ricaun.Nuke/Extensions/AssemblyExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,14 @@ public static string GetInformationalVersion(this Project project)
public static string GetAppId(this Project project) => project.ProjectId.ToString();

/// <summary>
/// Get FileVersionInfo of Greater Dlls
/// Get FileVersionInfo of Greater Dlls or Exe
/// </summary>
/// <param name="project"></param>
/// <returns></returns>
public static FileVersionInfo GetFileVersionInfo(this Project project)
{
return GetFileVersionInfoGreater(project.Directory, $"*{project.Name}*.dll");
return GetFileVersionInfoGreater(project.Directory, $"*{project.Name}*.dll") ??
GetFileVersionInfoGreater(project.Directory, $"*{project.Name}*.exe");
}

/// <summary>
Expand Down Expand Up @@ -172,12 +173,12 @@ private static FileVersionInfo GetFileVersionInfoGreater(string sourceDir, strin
{
FileVersionInfo fileVersionInfo = null;
Version version = new Version();
var dllFiles = Directory.GetFiles(sourceDir, searchPattern, SearchOption.AllDirectories);
foreach (var dll in dllFiles)
var files = Directory.GetFiles(sourceDir, searchPattern, SearchOption.AllDirectories);
foreach (var file in files)
{
try
{
var fileVersionInfoTest = FileVersionInfo.GetVersionInfo(dll);
var fileVersionInfoTest = FileVersionInfo.GetVersionInfo(file);
var fileVersion = new Version(fileVersionInfoTest.FileVersion);
if (version < fileVersion)
{
Expand Down
2 changes: 1 addition & 1 deletion ricaun.Nuke/ricaun.Nuke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<PropertyGroup>
<PackageId>ricaun.Nuke</PackageId>
<Version>1.8.0</Version>
<Version>1.8.1-alpha</Version>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit 03c2dc6

Please sign in to comment.