Visual studio 2010 VS2010-删除不在解决方案中的文件

Visual studio 2010 VS2010-删除不在解决方案中的文件,visual-studio-2010,resharper,Visual Studio 2010,Resharper,我需要删除在VisualStudio2010中已从解决方案中删除但尚未从文件系统中删除的文件(主要是.cs和.cshtml)。我知道,如果我选择“显示所有文件”选项,这些文件都会显示出来,但是,我不想手动搜索它们,因为这会花费很多时间,而且很容易出错 有没有办法列出这些文件?我正在使用Visual Studio 2010和Resharper 6.1(也许Resharper有一些选项可以做到这一点)。我根据@jovball的答案编写了一个PowerShell脚本。主要区别在于,我将接受一个.sln

我需要删除在VisualStudio2010中已从解决方案中删除但尚未从文件系统中删除的文件(主要是.cs和.cshtml)。我知道,如果我选择“显示所有文件”选项,这些文件都会显示出来,但是,我不想手动搜索它们,因为这会花费很多时间,而且很容易出错


有没有办法列出这些文件?我正在使用Visual Studio 2010和Resharper 6.1(也许Resharper有一些选项可以做到这一点)。

我根据@jovball的答案编写了一个PowerShell脚本。主要区别在于,我将接受一个.sln文件,并删除该解决方案中所有项目中排除的所有文件

以下是发布此答案时的脚本版本。但请检查最新版本

<#
.SYNOPSIS
Find all files excluded from a Visual Studio solution with options to delete.

.DESCRIPTION
Finds all excluded files in all projects in the provided Visual Studio solution with options to delete the files.

.PARAMETER Solution
The path to the .sln file

.PARAMETER VsVersion
The Visual Studio version (10, 11, 12) (Used to locate the tf.exe file)

.PARAMETER DeleteFromTfs
Mark files as pending deletion in TFS

.PARAMETER DeleteFromDisk
Delete the files directly from the disk

#>

[CmdletBinding()]
param(
    [Parameter(Position=0, Mandatory=$true)]
    [string]$Solution,
    [Parameter(Mandatory=$false)]
    [ValidateRange(10,12)] 
    [int] $VsVersion = 12,  
    [switch]$DeleteFromDisk,
    [switch]$DeleteFromTfs
)
$ErrorActionPreference = "Stop"
$tfPath = "${env:ProgramFiles(X86)}\Microsoft Visual Studio $VsVersion.0\Common7\IDE\TF.exe"
$solutionDir = Split-Path $Solution | % { (Resolve-Path $_).Path }

$projects = Select-String -Path $Solution -Pattern 'Project.*"(?<file>.*\.csproj)".*' `
    | % { $_.Matches[0].Groups[1].Value } `
    | % { Join-Path $solutionDir $_ }

$excluded = $projects | % {
    $projectDir = Split-Path $_

    $projectFiles = Select-String -Path $_ -Pattern '<(Compile|None|Content|EmbeddedResource) Include="(.*)".*' `
        | % { $_.Matches[0].Groups[2].Value } `
        | % { Join-Path $projectDir $_ }

    $diskFiles = Get-ChildItem -Path $projectDir -Recurse `
        | ? { !$_.PSIsContainer } `
        | % { $_.FullName } `
        | ? { $_ -notmatch "\\obj\\|\\bin\\|\\logs\\|\.user|\.*proj|App_Configuration\\|App_Data\\" }

    (compare-object $diskFiles $projectFiles -PassThru) | Where { $_.SideIndicator -eq '<=' }
} 

Write-Host "Found" $excluded.count "excluded files"

if ($DeleteFromTfs) 
{
    Write-Host "Marking excluded files as deleted in TFS..."
    $excluded | % {
        [Array]$arguments = @("delete", "`"$_`"")
        & "$tfPath" $arguments
    }
} 
elseif($DeleteFromDisk)
{
    Write-Host "Deleting excluded files from disk..."
    $excluded | % { Remove-Item -Path $_ -Force -Verbose}
}
else 
{
    Write-Host "Neither DeleteFromTfs or DeleteFromDisk was specified. Listing excluded files only..."
    $excluded
}

[CmdletBinding()]
param(
[参数(位置=0,强制=true)]
[字符串]$Solution,
[参数(必需=$false)]
[ValidateRange(10,12)]
[int]$VsVersion=12,
[开关]$DeleteFromDisk,
[开关]$DeleteFromTfs
)
$ErrorActionPreference=“停止”
$tfPath=“${env:ProgramFiles(X86)}\Microsoft Visual Studio$VsVersion.0\Common7\IDE\TF.exe”
$solutionDir=Split Path$Solution |%{(解析路径$..Path}
$projects=选择字符串-路径$Solution-模式'Project.*'(?.*\.csproj)'.'`
|%{$\.Matches[0]。组[1]。值}`
|%{加入路径$solutionDir$\u0}
$excluded=$projects |%{
$projectDir=分割路径$_

$projectFiles=Select String-Path$\uUX-Pattern'对已排除但未删除的文件是否附加了.exclude扩展名?这些文件不包含在csproj文件中。您所说的.exclude扩展名是什么意思?抱歉,它似乎只是ASP.NET项目功能。请检查此处可能存在的重复我明白您的观点,但作为e脚本是我的答案,它似乎是合适的链接。我会在这里发布当前版本的脚本,但如果我对其进行更改(很可能)并忘记更新我的答案,它可能会过时。我将尽最大努力确保链接保持不变。