Sam*_*ron 24 visual-studio-2010 visual-studio
如果我有10个文件打开并且我修改了我的csproj文件(例如:添加一个space)visual studio抱怨:
The project "XYZ" has been modified outside the environment. Press Reload to load the updated project from disk. Press Ignore to ignore the external changes. The change will be used the next time you open the project.
现在,我真的想重新加载,因为有重要的更改,但我不希望Visual Studio关闭所有打开的文件,而是希望它刷新仍然存在的文件并关闭丢失的文件.
有没有办法获得这种功能?
Sco*_*man 28
是的,我写了一个扩展来修复VS10和VS11中的这个问题:http://visualstudiogallery.msdn.microsoft.com/6705affd-ca37-4445-9693-f3d680c92f38
请享用.
Sam*_*ron 11
由于此功能未构建,我编写了以下宏:
Public Sub ReloadProject()
Dim oldFiles As List(Of String)
oldFiles = New List(Of String)
Dim projName = DTE.ActiveDocument.ProjectItem.ContainingProject.Name
For iDoc = DTE.Documents.Count To 1 Step -1
Dim name = (DTE.Documents.Item(iDoc).FullName)
oldFiles.Add(name)
DTE.Documents.Item(iDoc).Close(vsSaveChanges.vsSaveChangesPrompt)
Next
Dim projPath As String = DTE.Solution.Properties.Item("Name").Value.ToString() & "\" & projName
Dim solutionExplorer As Window = DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer)
solutionExplorer.Activate()
Dim solutionHierarchy As UIHierarchy = solutionExplorer.Object
Dim obj As Object = solutionHierarchy.GetItem(projPath)
obj.Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("Project.UnloadProject")
DTE.ExecuteCommand("Project.ReloadProject")
oldFiles.Reverse()
For Each file In oldFiles
Dim item = DTE.Solution.FindProjectItem(file)
If Not item Is Nothing Then
item.Open()
item.Document.Activate()
End If
Next
End Sub
Run Code Online (Sandbox Code Playgroud)
当我看到烦人的窗口告诉我重新加载时,我忽略了它.然后在重新加载后运行此宏.
| 归档时间: |
|
| 查看次数: |
2315 次 |
| 最近记录: |