Where solution build order is saved

拥有回忆 提交于 2021-02-07 21:01:50

问题


I have a solution which contains multiple projects (csproj & btproj). I'm actually running BizTalk 2013 R2, so I'm developing under Visual Studio 2013. I have many powershell scripts to deploy my applications and I have to enhance them.

I need to read or determine the projects build order of a solution to deploy my assemblies in this order. Ok I can get it under "Project->Project Dependencies", but where are these informations stored ? Or how can I determine them programatically with powershell ?

I tried this script, but it returns 0 dependencies for all my projects. Probably because my solution is 2013, and i'm using v14.0\Microsoft.Build.dll. v12.0\Microsoft.Build.dll return none projects.

Add-Type -Path (${env:ProgramFiles(x86)} + '\Reference Assemblies\Microsoft\MSBuild\v14.0\Microsoft.Build.dll')
$solutionFile = "sln file full path"
$solution = [Microsoft.Build.Construction.SolutionFile] $solutionFile

$projects = $solution.ProjectsByGuid.Values | Where-Object {($_.ProjectType -eq 'KnownToBeMSBuildFormat') -and ($_.ProjectName -notlike '*.BAM') -and ($_.ProjectName -notlike '*.Bindings')}
echo $projects.Count

foreach($project in $projects)
{ 
    echo $project.ProjectName $project.Dependencies.Count
}

Another way is to parse the btproj and csproj files, but it seems to be hard to code for a basic function.

来源:https://stackoverflow.com/questions/46345658/where-solution-build-order-is-saved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!