Table of Contents

Class VsProjectsFileHelper

Namespace
SunamoDevCode.Aps.Projs
Assembly
SunamoDevCode.dll

Use VsProjectFile,

public class VsProjectsFileHelper
Inheritance
VsProjectsFileHelper
Inherited Members
Extension Methods

Fields

cacheProjectReferences

Cache of project references indexed by csproj path.

public static Dictionary<string, ProjectReferences> cacheProjectReferences

Field Value

Dictionary<string, ProjectReferences>

Methods

AddFilesToCsproj(SolutionFolder, string, List<string>)

Adds missing files to a csproj as Compile items by comparing with already included files.

public static Task AddFilesToCsproj(SolutionFolder sln, string csprojpath, List<string> files)

Parameters

sln SolutionFolder

Solution folder containing the project.

csprojpath string

Path to the csproj file.

files List<string>

List of absolute file paths to add.

Returns

Task

AddItemGroupSdkStyle(string, ItemGroups, ItemGroupElement, bool)

Adds an ItemGroup element to an SDK-style .csproj file. Used in: MoveClassElementIntoSharedFileUC, AddFilesToCsproj. Works with pure XML classes, primarily for Compile tags.

public static Task AddItemGroupSdkStyle(string csprojPath, ItemGroups itemGroups, ItemGroupElement itemGroupElement, bool isWritingToStorage)

Parameters

csprojPath string

Path to the .csproj file.

itemGroups ItemGroups

The type of ItemGroup to add (Compile, Reference, etc.).

itemGroupElement ItemGroupElement

The ItemGroup element to add to the project.

isWritingToStorage bool

Whether to write changes to storage immediately.

Returns

Task

DuplicatedCsproj(ILogger, string)

Return paths of all csprojs

public static List<string> DuplicatedCsproj(ILogger logger, string path)

Parameters

logger ILogger

Logger instance for logging operations.

path string

Root path to search for csproj files.

Returns

List<string>

List of all csproj file paths found.

GetProjectReferences(string, Dictionary<string, XmlDocument>, UriKind)

Gets project references from a csproj file. Works for .NET Core and Framework. Requires Microsoft.Build. For full dependency tree, use BuildProjectsDependencyTree.

public static Task<ProjectReferences> GetProjectReferences(string csprojPath, Dictionary<string, XmlDocument> dictToAvoidCollectionWasChanged, UriKind uriKind = UriKind.Absolute)

Parameters

csprojPath string

Path to the csproj file.

dictToAvoidCollectionWasChanged Dictionary<string, XmlDocument>

Dictionary cache for XML documents to avoid collection-changed exceptions.

uriKind UriKind

Whether to return absolute or relative paths.

Returns

Task<ProjectReferences>

Project references found in the csproj.

GetTokens(string)

Splits a relative path into tokens using detected delimiter (backslash, forward slash, or quotes).

public static List<string> GetTokens(string relativePath)

Parameters

relativePath string

Relative path to tokenize.

Returns

List<string>

List of path tokens.

SetTargetFrameworksUap(string, string, string)

Sets the target frameworks for UAP (Universal Application Platform) projects. This method has been moved to SunamoMicrosoftBuild.

public static void SetTargetFrameworksUap(string csprojPath, string targetFramework, string minFramework)

Parameters

csprojPath string

Path to the .csproj file.

targetFramework string

The target framework version.

minFramework string

The minimum framework version.

Exceptions

NotImplementedException

This method has been moved to another assembly.

XmlClassLibraryFromTemplate(string)

Vytvoří mi nový vsproj z templaty VS2019

public static Task<string> XmlClassLibraryFromTemplate(string safeProjectName)

Parameters

safeProjectName string

Returns

Task<string>