Skip to content

Commit 7e2b0d7

Browse files
authored
Merge pull request #14 from meokullu/new_version_0001
v1.14.0
2 parents 421c0e0 + 24b531a commit 7e2b0d7

4 files changed

Lines changed: 48 additions & 20 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
#### Security
1717
-->
1818

19+
### [1.4.0] (2026-03-15)
20+
#### Added
21+
* `CurrentDirectory`, `StartupPath` and `AppName` properties are added to `NuGetVersionChecker` class. These properties are used in `NuGetVersionCheck()` method to get current directory, startup path and application name for easier use of this method in console applications.
22+
* `GetFilePath()` method is added to `NuGetVersionChecker` class. This method is used in `NuGetVersionCheck()` method to get file path for .csproj file based on entry directory, startup path and application name.
23+
1924
### [1.3.0] (2025-11-24)
2025
#### Added
2126
* Null check for return package data in `CheckVersionAsync(string path, bool includePrerelease)` method. If it is null, return empty list of Packages.

NuGetVersionChecker/NuGetVersionChecker.csproj

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,22 @@
1111
<RepositoryType>git</RepositoryType>
1212
<PackageTags>version; version-checker; version-compare; NuGet; Nuget-Package; version-check; Dependency</PackageTags>
1313
<PackageReleaseNotes>
14-
v1.3.0
15-
* Null check for return package data in `CheckVersionAsync(string path, bool includePrerelease)` method. If it is null, return empty list of Packages.
16-
* Null check for return package data in `CheckVersionAsync(List&lt;string&gt;
17-
pathList, bool includePrerelease)` method. If it is null, return empty list of Packages.
18-
* Network availability check before making NuGet API calls in `GetPackageFromNuGetAsync(string packageName, bool includePrerelease)` method. If network is unavailable, it return empty Package.
19-
* Network availability check before making NuGet API calls in `GetPackagesFromNuGetAsync(List&lt;string&gt; packageNameList, bool includePrerelease)` method. If network is unavailable, it return empty list of Packages.
20-
21-
See changelog (https://github.com/meokullu/NuGetVersionChecker/blob/master/CHANGELOG.md)
22-
</PackageReleaseNotes>
23-
<AssemblyVersion>1.3.0</AssemblyVersion>
24-
<FileVersion>1.3.0</FileVersion>
14+
v1.4.0
15+
* CurrentDirectory, StartupPath and AppName properties are added.
16+
* GetFilePath() method is added. You can get the .csproj file path of the project with this method.
17+
18+
See changelog (https://github.com/meokullu/NuGetVersionChecker/blob/master/CHANGELOG.md)
19+
</PackageReleaseNotes>
20+
<AssemblyVersion>1.4.0</AssemblyVersion>
21+
<FileVersion>1.4.0</FileVersion>
2522
<Title>Nuget Version Checker</Title>
2623
<PackageReadmeFile>README.md</PackageReadmeFile>
2724
<PackageProjectUrl>https://meokullu.github.io/NuGetVersionChecker/</PackageProjectUrl>
2825
<RepositoryUrl>https://github.com/meokullu/NuGetVersionChecker</RepositoryUrl>
2926
<ApplicationIcon>Resources\icon256.ico</ApplicationIcon>
3027
<Copyright>Enes Okullu</Copyright>
3128
<PackageIcon>icon128.png</PackageIcon>
32-
<Version>1.3.0</Version>
29+
<Version>1.4.0</Version>
3330
<PackageLicenseFile>LICENSE</PackageLicenseFile>
3431
</PropertyGroup>
3532

NuGetVersionChecker/src/ParseFile.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Diagnostics;
5+
using System.IO;
6+
using System.Reflection;
57
using System.Xml;
68

79
namespace NuGetVersionChecker
@@ -103,5 +105,35 @@ public static List<Package> GetPackages(string path)
103105
// Returning list of packages.
104106
return packages;
105107
}
108+
109+
/// <summary>
110+
/// Gets the full path of the current working directory of the application.
111+
/// </summary>
112+
/// <remarks>The current directory is the directory from which the process is started, unless it is
113+
/// changed by the application. The value may differ between threads or after calling methods that change the
114+
/// current directory, such as System.IO.Directory.SetCurrentDirectory. The returned path does not end with a
115+
/// directory separator character.</remarks>
116+
public static string CurrentDirectory => System.IO.Directory.GetCurrentDirectory();
117+
118+
/// <summary>
119+
/// Gets the full path of the startup directory of the application, which is the parent directory of the current working directory. It assumes that the .csproj file is located three levels up from the current directory.
120+
/// </summary>
121+
public static string StartupPath => Directory.GetParent(CurrentDirectory).Parent.Parent.FullName;
122+
123+
/// <summary>
124+
/// Gets the name of the application, which is derived from the entry assembly's name. It assumes that the .csproj file has the same name as the application.
125+
/// </summary>
126+
public static string AppName => Assembly.GetEntryAssembly().GetName().Name;
127+
128+
/// <summary>
129+
/// Constructs the full file path to the .csproj file based on the startup directory and application name.
130+
/// </summary>
131+
/// <returns>The full file path to the .csproj file.</returns>
132+
/// <returns>Exact path of .csproj file.</returns>
133+
public static string GetFilePath()
134+
{
135+
// Returning path of .csproj file.
136+
return $"{StartupPath}\\{AppName}.csproj";
137+
}
106138
}
107139
}

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,8 @@ NuGetVersionCheck();
4949

5050
```
5151
internal static void NuGetVersionCheck()
52-
{
53-
string currentDirectory = System.IO.Directory.GetCurrentDirectory();
54-
55-
string startupPath = Directory.GetParent(currentDirectory).Parent.Parent.FullName;
56-
57-
string appName = Assembly.GetExecutingAssembly().GetName().Name;
58-
59-
List<Package> result = CheckVersionAsync($"{startupPath}//{appName}.csproj").GetAwaiter().GetResult();
52+
{
53+
List<Package> result = CheckVersionAsync(GetFilePath()).GetAwaiter().GetResult();
6054
6155
foreach (Package package in result.Where(p => p.UpdateAvailable))
6256
{

0 commit comments

Comments
 (0)