How to query MSBUILD file for list of supported targets?

后端 未结 6 442
遥遥无期
遥遥无期 2020-12-14 01:43

Is there any way to ask msbuild what build targets provided msbuild file support? If there is no way to do it in command prompt? May be it could be done programmatically?

6条回答
  •  感动是毒
    2020-12-14 02:30

    I suggest you use PowerShell:

    Select-Xml `
        -XPath //b:Target `
        -Path path-to-build-file `
        -Namespace @{ b = 'http://schemas.microsoft.com/developer/msbuild/2003' } |
        Select-Object -ExpandProperty Node |
        Format-Table -Property Name, DependsOnTargets -AutoSize
    

    The XPath query will find all Target elements and display the target name and dependencies in table format. Here is a sample that selects the 10 first targets from Microsoft.Web.Publishing.targets:

    PS C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web> Select-Xml `
        -XPath //b:Target `
        -Path Microsoft.Web.Publishing.targets `
        -Namespace @{ b = 'http://schemas.microsoft.com/developer/msbuild/2003' } |
        Select-Object -ExpandProperty Node |
        Sort-Object -Property Name |
        Select-Object -First 10 |
        Format-Table -Property Name, DependsOnTargets -AutoSize
    
    Name                                    DependsOnTargets                       
    ----                                    ----------------                       
    _CheckPublishToolsUpToDate                                                     
    _CheckRemoteFx45                                                               
    _CleanWPPIfNeedTo                                                              
    _DetectDbDacFxProvider                                                         
    _WPPCopyWebApplication                  $(_WPPCopyWebApplicationDependsOn)     
    AddContentPathToSourceManifest          $(AddContentPathToSourceManifestDepe...
    AddDeclareParametersItems               $(AddDeclareParametersItemsDependsOn)  
    AddDeclareParametersItemsForContentPath $(AddDeclareParametersItemsForConten...
    AddDeclareParametersItemsForIis6        $(AddDeclareParametersItemsForIis6De...
    AddDeclareParametersItemsForIis7        $(AddDeclareParametersItemsForIis7De...
    

提交回复
热议问题