Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 查找编译到.NET3.5控制台应用程序的所有VS项目_Visual Studio_Powershell_Select String - Fatal编程技术网

Visual studio 查找编译到.NET3.5控制台应用程序的所有VS项目

Visual studio 查找编译到.NET3.5控制台应用程序的所有VS项目,visual-studio,powershell,select-string,Visual Studio,Powershell,Select String,我有一个嵌套很深的存储库,有很多VisualStudio项目。我需要找到所有项目,它们具有targetframework3.5和输出类型“控制台应用程序” 我发现控制台应用程序的csproj文件中有以下内容: <OutputType>Exe</OutputType> Exe 带有窗口的应用程序具有以下功能: <OutputType>WinExe</OutputType> WinExe 这使我能够找到所有扩展名为csproj的文件,这些文件将

我有一个嵌套很深的存储库,有很多VisualStudio项目。我需要找到所有项目,它们具有targetframework3.5输出类型“控制台应用程序”

我发现控制台应用程序的csproj文件中有以下内容:

<OutputType>Exe</OutputType>
Exe
带有窗口的应用程序具有以下功能:

<OutputType>WinExe</OutputType>
WinExe
这使我能够找到所有扩展名为csproj的文件,这些文件将编译到控制台应用程序

$csproj_ConsoleExes = gci -Recurse *.csproj | select-string "<OutputType>Exe</OutputType>"
$csproj_ConsoleExes=gci-Recurse*.csproj |选择字符串“Exe”
接下来我需要做的是:我只需要过滤那些使用目标框架3.5的项目。但是由于$csproj_控制台包含搜索结果,我不知道如何再次应用选择字符串。 选择字符串仅适用于类型为FileInfo的输入对象


非常感谢您的帮助。

您可以使用以下命令将$csproj_ConsoleExes中的项目转换为键入FileInfo

$csproj_Console_Items = $csproj_ConsoleExes| select Path | get-item
上面的一行首先获取每个项的路径,并将其输送到get item,然后将其转换为FileInfo对象

然后,您可以找到包含TargetFrameworkVersion

$csproj_Console_TargetFrameworkVersion=$csproj_Console_Items | select-string "<TargetFrameworkVersion>"
$csproj_Console_TargetFrameworkVersion=$csproj_Console_Items |选择字符串“”
现在,您可以再次获取路径并将其输送到get item以获取新的FileInfo类型集合。

您可以利用的功能接受多个搜索模式,这允许您随后使用来确定两个模式匹配的所有文件:

Get-ChildItem -Recurse -Filter *.csproj |
  Select-String '<OutputType>Exe</OutputType>',
                '<TargetFramework>net35</TargetFramework>' | 
    Group-Object Path |
      Where-Object Count -eq 2 | 
        ForEach-Object Name
Get ChildItem-Recurse-Filter*.csproj|
选择字符串“Exe”,
“网络35”|
组对象路径|
其中对象计数-等式2 |
ForEach对象名
上面输出了找到这两种模式的所有
*.csproj
文件的完整路径

注意:这种方法只有在每个搜索模式下,每个输入文件最多匹配一行时才有效,但是
.csproj
文件应该是这样