Table of Contents

Class CsprojShared

Namespace
SunamoDevCode
Assembly
SunamoDevCode.dll

EN: Although this is from CommandsToAllCsprojs.Shared, it is useful for all CommandsToAll* projects EN: Not adding it there as a single file but as an entire csproj CZ: Toto je sice z CommandsToAllCsprojs.Shared ale hodí se na to všechny CommandsToAll* CZ: Nepřidávám to tam jako soubor ale jako celý csproj

public class CsprojShared
Inheritance
CsprojShared
Inherited Members
Extension Methods

Methods

DetectIsSlnOrCsprojFolder(ILogger, string, WhatIsExcepted)

Detects whether the folder contains a solution or csproj file. Returns true for sln, false for csproj, null for neither or both.

public static bool? DetectIsSlnOrCsprojFolder(ILogger logger, string path, WhatIsExcepted whatIsExcepted)

Parameters

logger ILogger

Logger instance.

path string

Folder path to check.

whatIsExcepted WhatIsExcepted

Preference when both sln and csproj exist.

Returns

bool?

True for sln, false for csproj, null if neither or ambiguous.

GetCsprojForFolder(ILogger, string, bool)

Gets the single .csproj file in the given folder.

public static string? GetCsprojForFolder(ILogger logger, string path, bool isThrowingExceptionOrReturningNull)

Parameters

logger ILogger

Logger instance.

path string

Folder path to search.

isThrowingExceptionOrReturningNull bool

If true, throws on not found or multiple; if false, returns null.

Returns

string

Path to the csproj file, or null if not found.

GetExtForFolder(ILogger, string, bool, string)

Gets the single file matching the extension in the given folder.

public static string? GetExtForFolder(ILogger logger, string path, bool isThrowingExceptionOrReturningNull, string ext)

Parameters

logger ILogger

Logger instance.

path string

Folder path to search.

isThrowingExceptionOrReturningNull bool

If true, throws on not found or multiple; if false, returns null.

ext string

File extension to search for (with or without leading dot).

Returns

string

Path to the matching file, or null if not found.

GetSlnForFolder(ILogger, string, bool)

Gets the single solution file (.sln, .slnx, .slnj) in the given folder.

public static string? GetSlnForFolder(ILogger logger, string path, bool isThrowingExceptionOrReturningNull)

Parameters

logger ILogger

Logger instance.

path string

Folder path to search.

isThrowingExceptionOrReturningNull bool

If true, throws on not found; if false, returns null.

Returns

string

Path to the solution file, or null if not found.

HasSlnFileInUpFolder(ILogger, string, out string)

Checks whether a solution file exists in the parent folder of the given csproj path.

public static bool HasSlnFileInUpFolder(ILogger logger, string csprojPath, out string slnFolder)

Parameters

logger ILogger

Logger instance.

csprojPath string

Path to the csproj file.

slnFolder string

Output: the parent folder path where solution files were searched.

Returns

bool

True if at least one solution file exists in the parent folder.