[英]How to build VS solution folder from powershell
From Visual Studio I can build several projects grouped by solution folder by right click -> Build. 从Visual Studio我可以通过右键单击 - > Build来构建按解决方案文件夹分组的多个项目。
Is there any command line / power shell alternative for that? 是否有替代命令行/电源shell?
In the screenshot above just do following: 在上面的截图中,请执行以下操作:
cd [directory with WindowsFormsApplication1.sln]
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
Powershell is just "console". Powershell只是“控制台”。 For building sln or csproj you need to msbuild.exe which is a tool for building .NET projects 要构建sln或csproj,您需要使用msbuild.exe ,这是一个用于构建.NET项目的工具
If you want only to build one solution folder from sln it is not so easy because folders in Visual Studio are virtual and you need to parse sln file to find folders 如果你只想从sln构建一个解决方案文件夹,那就不那么容易了,因为Visual Studio中的文件夹是虚拟的,你需要解析sln文件来查找文件夹
Update 更新
The following code will parse sln file and run msbuild for project which belongs to folder: 以下代码将解析sln文件并运行属于文件夹的项目的msbuild:
param([string]$slnPath=".\YourSLN.sln", [string]$VsFolderName="Your_folder")
$slnContent = Get-Content $slnPath
$folderLine = $slnContent | ?{$_.Contains("2150E333-8FDC-42A3-9474-1A3956D46DE8")} | ?{$_.Contains($VsFolderName)}
$guid = $folderLine.Split(", ")[-1].Replace('"',"")
#Write-host $guid
$csprojGuids = $slnContent | ?{$_.Contains("= "+$guid)} | %{$_.Split("=")[-2].Trim()}
#Write-Host $csprojGuids
for($i=0; $i -lt $csprojGuids.count; $i++){
$toFind = $csprojGuids[$i]
$def = $slnContent | ?{$_.Contains("Project")} | ?{$_.Contains($csprojGuids[$i])} | %{$_.Split(",")[-2].Trim().Replace('"','')}
Write-Host "building" $def
C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe $def
}
You can use DTE to get paths of projects and then pass them to msbuild. 您可以使用DTE获取项目路径,然后将它们传递给msbuild。 Run this from Package Manager Console (presuming msbuild is in your %path%): 从包管理器控制台运行此命令(假设msbuild在您的%path%中):
project|% dte|% solution|? projectname -eq NewFolder1|% projectitems|% object|% {msbuild $_.fullname}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.