C# Класс MSBuild.Abstractions.MSBuildHelpers

Static helper methods for working with general MSBuildisms.
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
AddImportWindowsDesktopTargets ( ProjectPropertyGroupElement propGroup ) : void

Adds the ImportWindowsDesktopTargets=true property to ensure builds targeting .NET Framework will succeed.

AddUseWPF ( ProjectPropertyGroupElement propGroup ) : void

Adds the UseWPF=true property to the top-level project property group.

AddUseWinForms ( ProjectPropertyGroupElement propGroup ) : void

Adds the UseWindowsForms=True property to the top-level project property group.

AddUseWinUI ( ProjectPropertyGroupElement propGroup ) : void

Adds the UseWinUI=true property to the top-level project property group.

ConditionToDimensionValues ( string condition, ImmutableDictionary &dimensionalValues ) : bool

Tries to parse an MSBuild condition to a dimensional vector only matches standard pattern: '$(DimensionName1)|$(DimensionName2)|...|$(DimensionNameN)'=='DimensionValue1|...|DimensionValueN'.

FrameworkHasAValueTuple ( string tfm ) : bool

Given a TFM string, determines if that TFM has an explicit System.ValueTuple reference.

GetAllProjectTypeGuids ( IProjectRootElement root ) : IEnumerable

Gets a flat list of all project type guids.

GetConfigurationName ( ImmutableDictionary dimensionValues ) : string

Returns a name of a configuration like Debug|AnyCPU.

GetConfigurationName ( string condition ) : string

Returns a name of a configuration like Debug|AnyCPU.

GetOrCreatePackageReferencesItemGroup ( IProjectRootElement rootElement ) : ProjectItemGroupElement

Finds the item group where PackageReferences are specified. Usually there is only one.

GetOrCreateTopLevelPropertyGroup ( BaselineProject baselineProject, IProjectRootElement projectRootElement ) : ProjectPropertyGroupElement

Gets the top-level property group, and if it doesn't exist, creates it.

GetOrCreateTopLevelPropertyGroupWithTFM ( IProjectRootElement rootElement ) : ProjectPropertyGroupElement

Finds the property group with the TFM specified, which is normally the top-level property group.

GetPackagesConfigItem ( ProjectItemGroupElement packagesConfigItemGroup ) : ProjectItemElement

Finds the packages.config item in its containing item group.

GetPackagesConfigItemGroup ( IProjectRootElement root ) : ProjectItemGroupElement?

Finds the item group where a packages.config is included. Assumes only one.

HasProjectTypeGuidsNode ( IProjectRootElement root ) : bool

Checks if a root has a project type guids node.

HasWPFOrWinForms ( ProjectPropertyGroupElement propGroup ) : bool
IsAspNetCore ( IProjectRootElement projectRoot, string tfm ) : bool

Determines if a project should be treated as an ASP.NET Core project (as opposed to classic ASP.NET). Returns true if the project is a web app (since there's no good way to build an ASP.NET app with an SDK-style project except to upgrade to ASP.NET Core) or the project has web dependencies and will target .NET/.NET Core.

IsDesktop ( IProjectRootElement projectRoot ) : bool

Determines if a given project references Desktop assemblies.

IsNETFrameworkMSTestProject ( IProjectRootElement projectRoot ) : bool

Determines if a project is a .NET Framework MSTest project by looking at its references.

IsNotNetFramework ( string tfm ) : bool

Checks if a given TFM is not .NET Framework.

IsTargetFromNuGetPackage ( ProjectImportElement import ) : bool

Checks if an import is a target that comes from the packages directory (which would mean it's probably brought in via a NuGet package).

IsUwp ( IProjectRootElement projectRoot ) : bool

Determines if a given project is UWP.

IsValidMetadataForConversionPurposes ( IProjectMetadata projectMetadata ) : bool

Checks if a metadata item can stay or if it needs to be converted.

IsWPF ( IProjectRootElement projectRoot ) : bool

Determines if a given project is a WPF project by looking at its references.

IsWeb ( IProjectRootElement projectRoot ) : bool

Determines if a given project references ASP.NET assemblies.

IsWebApp ( IProjectRootElement projectRoot ) : bool

Determines if a given project uses ASP.NET web app project type guid.

IsWinForms ( IProjectRootElement projectRoot ) : bool

Determines if a given project is a WinForms project by looking at its references.

IsWindows ( string tfm ) : bool

Checks if a given TFM include -windows.

Приватные методы

Метод Описание
DimensionalValuePairsToCondition ( ImmutableDictionary dimensionalValues ) : string

Converts configuration dimensional value vector to a msbuild condition Use the standard format of '$(DimensionName1)|$(DimensionName2)|...|$(DimensionNameN)'=='DimensionValue1|...|DimensionValueN'.

GetPackageReferences ( ProjectItemGroupElement itemGroup ) : IEnumerable

Gets all PackageReference items from a given item group.

GetReferences ( ProjectItemGroupElement itemGroup ) : IEnumerable

Gets all Reference items from a given item group.

Описание методов

AddImportWindowsDesktopTargets() публичный статический Метод

Adds the ImportWindowsDesktopTargets=true property to ensure builds targeting .NET Framework will succeed.
public static AddImportWindowsDesktopTargets ( ProjectPropertyGroupElement propGroup ) : void
propGroup ProjectPropertyGroupElement
Результат void

AddUseWPF() публичный статический Метод

Adds the UseWPF=true property to the top-level project property group.
public static AddUseWPF ( ProjectPropertyGroupElement propGroup ) : void
propGroup ProjectPropertyGroupElement
Результат void

AddUseWinForms() публичный статический Метод

Adds the UseWindowsForms=True property to the top-level project property group.
public static AddUseWinForms ( ProjectPropertyGroupElement propGroup ) : void
propGroup ProjectPropertyGroupElement
Результат void

AddUseWinUI() публичный статический Метод

Adds the UseWinUI=true property to the top-level project property group.
public static AddUseWinUI ( ProjectPropertyGroupElement propGroup ) : void
propGroup ProjectPropertyGroupElement
Результат void

ConditionToDimensionValues() публичный статический Метод

Tries to parse an MSBuild condition to a dimensional vector only matches standard pattern: '$(DimensionName1)|$(DimensionName2)|...|$(DimensionNameN)'=='DimensionValue1|...|DimensionValueN'.
public static ConditionToDimensionValues ( string condition, ImmutableDictionary &dimensionalValues ) : bool
condition string msbuild condition string.
dimensionalValues ImmutableDictionary configuration dimensions vector (output).
Результат bool

FrameworkHasAValueTuple() публичный статический Метод

Given a TFM string, determines if that TFM has an explicit System.ValueTuple reference.
public static FrameworkHasAValueTuple ( string tfm ) : bool
tfm string
Результат bool

GetAllProjectTypeGuids() публичный статический Метод

Gets a flat list of all project type guids.
public static GetAllProjectTypeGuids ( IProjectRootElement root ) : IEnumerable
root IProjectRootElement
Результат IEnumerable

GetConfigurationName() публичный статический Метод

Returns a name of a configuration like Debug|AnyCPU.
public static GetConfigurationName ( ImmutableDictionary dimensionValues ) : string
dimensionValues ImmutableDictionary
Результат string

GetConfigurationName() публичный статический Метод

Returns a name of a configuration like Debug|AnyCPU.
public static GetConfigurationName ( string condition ) : string
condition string
Результат string

GetOrCreatePackageReferencesItemGroup() публичный статический Метод

Finds the item group where PackageReferences are specified. Usually there is only one.
public static GetOrCreatePackageReferencesItemGroup ( IProjectRootElement rootElement ) : ProjectItemGroupElement
rootElement IProjectRootElement
Результат ProjectItemGroupElement

GetOrCreateTopLevelPropertyGroup() публичный статический Метод

Gets the top-level property group, and if it doesn't exist, creates it.
public static GetOrCreateTopLevelPropertyGroup ( BaselineProject baselineProject, IProjectRootElement projectRootElement ) : ProjectPropertyGroupElement
baselineProject BaselineProject
projectRootElement IProjectRootElement
Результат ProjectPropertyGroupElement

GetOrCreateTopLevelPropertyGroupWithTFM() публичный статический Метод

Finds the property group with the TFM specified, which is normally the top-level property group.
public static GetOrCreateTopLevelPropertyGroupWithTFM ( IProjectRootElement rootElement ) : ProjectPropertyGroupElement
rootElement IProjectRootElement
Результат ProjectPropertyGroupElement

GetPackagesConfigItem() публичный статический Метод

Finds the packages.config item in its containing item group.
public static GetPackagesConfigItem ( ProjectItemGroupElement packagesConfigItemGroup ) : ProjectItemElement
packagesConfigItemGroup ProjectItemGroupElement
Результат ProjectItemElement

GetPackagesConfigItemGroup() публичный статический Метод

Finds the item group where a packages.config is included. Assumes only one.
public static GetPackagesConfigItemGroup ( IProjectRootElement root ) : ProjectItemGroupElement?
root IProjectRootElement
Результат ProjectItemGroupElement?

HasProjectTypeGuidsNode() публичный статический Метод

Checks if a root has a project type guids node.
public static HasProjectTypeGuidsNode ( IProjectRootElement root ) : bool
root IProjectRootElement
Результат bool

HasWPFOrWinForms() публичный статический Метод

public static HasWPFOrWinForms ( ProjectPropertyGroupElement propGroup ) : bool
propGroup ProjectPropertyGroupElement
Результат bool

IsAspNetCore() публичный статический Метод

Determines if a project should be treated as an ASP.NET Core project (as opposed to classic ASP.NET). Returns true if the project is a web app (since there's no good way to build an ASP.NET app with an SDK-style project except to upgrade to ASP.NET Core) or the project has web dependencies and will target .NET/.NET Core.
public static IsAspNetCore ( IProjectRootElement projectRoot, string tfm ) : bool
projectRoot IProjectRootElement
tfm string
Результат bool

IsDesktop() публичный статический Метод

Determines if a given project references Desktop assemblies.
public static IsDesktop ( IProjectRootElement projectRoot ) : bool
projectRoot IProjectRootElement
Результат bool

IsNETFrameworkMSTestProject() публичный статический Метод

Determines if a project is a .NET Framework MSTest project by looking at its references.
public static IsNETFrameworkMSTestProject ( IProjectRootElement projectRoot ) : bool
projectRoot IProjectRootElement
Результат bool

IsNotNetFramework() публичный статический Метод

Checks if a given TFM is not .NET Framework.
public static IsNotNetFramework ( string tfm ) : bool
tfm string
Результат bool

IsTargetFromNuGetPackage() публичный статический Метод

Checks if an import is a target that comes from the packages directory (which would mean it's probably brought in via a NuGet package).
public static IsTargetFromNuGetPackage ( ProjectImportElement import ) : bool
import ProjectImportElement
Результат bool

IsUwp() публичный статический Метод

Determines if a given project is UWP.
public static IsUwp ( IProjectRootElement projectRoot ) : bool
projectRoot IProjectRootElement
Результат bool

IsValidMetadataForConversionPurposes() публичный статический Метод

Checks if a metadata item can stay or if it needs to be converted.
public static IsValidMetadataForConversionPurposes ( IProjectMetadata projectMetadata ) : bool
projectMetadata IProjectMetadata
Результат bool

IsWPF() публичный статический Метод

Determines if a given project is a WPF project by looking at its references.
public static IsWPF ( IProjectRootElement projectRoot ) : bool
projectRoot IProjectRootElement
Результат bool

IsWeb() публичный статический Метод

Determines if a given project references ASP.NET assemblies.
public static IsWeb ( IProjectRootElement projectRoot ) : bool
projectRoot IProjectRootElement
Результат bool

IsWebApp() публичный статический Метод

Determines if a given project uses ASP.NET web app project type guid.
public static IsWebApp ( IProjectRootElement projectRoot ) : bool
projectRoot IProjectRootElement
Результат bool

IsWinForms() публичный статический Метод

Determines if a given project is a WinForms project by looking at its references.
public static IsWinForms ( IProjectRootElement projectRoot ) : bool
projectRoot IProjectRootElement
Результат bool

IsWindows() публичный статический Метод

Checks if a given TFM include -windows.
public static IsWindows ( string tfm ) : bool
tfm string
Результат bool