in my vstemplate file, for my project template, I decided to add an extra item:
<TemplateContent>
<Project File="DnnProjectSystem.dnnproj" ReplaceParameters="true">
<!--
These are the items which will show up when a new project is created using the custom project system.
Items referenced in here must also be referenced in the project file.
-->
<ProjectItem>Properties\AssemblyInfo.cs</ProjectItem>
<ProjectItem ItemType="DnnManifest">manifest.dnn</ProjectItem>
<!--<ProjectItem OpenInEditor="true" ReplaceParameters="true">Program.cs</ProjectItem>-->
</Project>
The idea being that when the project is created, the "manifest.dnn" file will automatically be included in the project, with a "DnnManifest" item type.
However one important point, is that my custom project targets are added via a nuget install step in the vstemplate:
The issue is, when I create the project, the manifest file is not added, and I get an error window displayed, saying an error was logged. Looking at the log I see this:
===================
26/02/2017 17:17:09
Recoverable
System.AggregateException: One or more errors occurred. ---> Microsoft.VisualStudio.ProjectSystem.ProjectTreeCorruptionException: Failed to update the project tree. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Immutable.ImmutableDictionary`2.get_Item(TKey key)
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.HandleRenamedItems(IProjectTree tree, IImmutableDictionary`2 changeMap, IProjectChangeDescription change, IImmutableDictionary`2 projectData, HashSet`1 dynamicDependentChildrenAffected, ConfiguredProjectExports configuredProjectExports)
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.OnProjectSubscriptionChanged(IProjectTree originalTree, ConfiguredProjectExports configuredProjectExports, PhysicalProjectTreeInputData updateInput, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.OnProjectSubscriptionChanged(IProjectTree originalTree, ConfiguredProjectExports configuredProjectExports, PhysicalProjectTreeInputData updateInput, CancellationToken cancellationToken)
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.<>c__DisplayClass172_0.<ProjectSubscriptionService_ChangedAsync>b__0(IProjectVersionedValue`1 treeSnapshot, ConfiguredProjectExports configuredProjectExports, CancellationToken ct)
at Microsoft.VisualStudio.ProjectSystem.ProjectTreeProviderBase.TreeUpdateSubmission.<UpdateTree>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.VisualStudio.ProjectSystem.ProjectTreeProviderBase.<>c__DisplayClass95_0.<<Initialize>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.ProjectTreeProviderBase.<>c__DisplayClass102_0.<<SubmitTreeUpdateAsync>b__0>d.MoveNext()
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.VisualStudio.ProjectSystem.ProjectTreeCorruptionException: Failed to update the project tree. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Immutable.ImmutableDictionary`2.get_Item(TKey key)
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.HandleRenamedItems(IProjectTree tree, IImmutableDictionary`2 changeMap, IProjectChangeDescription change, IImmutableDictionary`2 projectData, HashSet`1 dynamicDependentChildrenAffected, ConfiguredProjectExports configuredProjectExports)
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.OnProjectSubscriptionChanged(IProjectTree originalTree, ConfiguredProjectExports configuredProjectExports, PhysicalProjectTreeInputData updateInput, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.OnProjectSubscriptionChanged(IProjectTree originalTree, ConfiguredProjectExports configuredProjectExports, PhysicalProjectTreeInputData updateInput, CancellationToken cancellationToken)
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.<>c__DisplayClass172_0.<ProjectSubscriptionService_ChangedAsync>b__0(IProjectVersionedValue`1 treeSnapshot, ConfiguredProjectExports configuredProjectExports, CancellationToken ct)
at Microsoft.VisualStudio.ProjectSystem.ProjectTreeProviderBase.TreeUpdateSubmission.<UpdateTree>d__25.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.VisualStudio.ProjectSystem.ProjectTreeProviderBase.<>c__DisplayClass95_0.<<Initialize>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.ProjectSystem.ProjectTreeProviderBase.<>c__DisplayClass102_0.<<SubmitTreeUpdateAsync>b__0>d.MoveNext()
Project: c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\DnnExtension87.dnnproj
PRIOR tree:
DnnExtension87 (visibility: visible, capabilities: {ProjectRoot}), FilePath: ""
bin (visibility: invisible, capabilities: {FileSystemEntity Folder IncludeInProjectCandidate VisibleOnlyInShowAllFiles}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\bin\"
Debug (visibility: visible, capabilities: {FileSystemEntity Folder IncludeInProjectCandidate}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\bin\Debug\"
obj (visibility: invisible, capabilities: {FileSystemEntity Folder IncludeInProjectCandidate VisibleOnlyInShowAllFiles}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\obj\"
Debug (visibility: visible, capabilities: {FileSystemEntity Folder IncludeInProjectCandidate}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\obj\Debug\"
CoreCompileInputs.cache (visibility: visible, capabilities: {FileOnDisk FileSystemEntity IncludeInProjectCandidate}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\obj\Debug\CoreCompileInputs.cache"
Properties (visibility: visible, capabilities: {FileSystemEntity Folder}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\Properties\"
AssemblyInfo.cs (visibility: visible, capabilities: {FileOnDisk FileSystemEntity SourceFile}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\Properties\AssemblyInfo.cs"
DnnExtension87.dnnproj (visibility: invisible, capabilities: {AlwaysInvisible FileOnDisk FileSystemEntity HiddenProjectSettingsFile IncludeInProjectCandidate}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\DnnExtension87.dnnproj"
packages.config (visibility: visible, capabilities: {FileOnDisk FileSystemEntity SourceFile}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\packages.config"
readme.txt (visibility: visible, capabilities: {FileOnDisk FileSystemEntity SourceFile}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\readme.txt"
ACTUAL tree:
DnnExtension87 (visibility: visible, capabilities: {ProjectRoot}), FilePath: ""
bin (visibility: invisible, capabilities: {FileSystemEntity Folder IncludeInProjectCandidate VisibleOnlyInShowAllFiles}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\bin\"
Debug (visibility: visible, capabilities: {FileSystemEntity Folder IncludeInProjectCandidate}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\bin\Debug\"
obj (visibility: invisible, capabilities: {FileSystemEntity Folder IncludeInProjectCandidate VisibleOnlyInShowAllFiles}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\obj\"
Debug (visibility: visible, capabilities: {FileSystemEntity Folder IncludeInProjectCandidate}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\obj\Debug\"
CoreCompileInputs.cache (visibility: visible, capabilities: {FileOnDisk FileSystemEntity IncludeInProjectCandidate}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\obj\Debug\CoreCompileInputs.cache"
Properties (visibility: visible, capabilities: {FileSystemEntity Folder}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\Properties\"
AssemblyInfo.cs (visibility: visible, capabilities: {FileOnDisk FileSystemEntity SourceFile}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\Properties\AssemblyInfo.cs"
DnnExtension87.dnnproj (visibility: invisible, capabilities: {AlwaysInvisible FileOnDisk FileSystemEntity HiddenProjectSettingsFile IncludeInProjectCandidate}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\DnnExtension87.dnnproj"
packages.config (visibility: visible, capabilities: {FileOnDisk FileSystemEntity SourceFile}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\packages.config"
readme.txt (visibility: visible, capabilities: {FileOnDisk FileSystemEntity SourceFile}), FilePath: "c:\users\darrell\documents\visual studio 2017\Projects\DnnExtension87\DnnExtension87\readme.txt"
Inner exception:
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Immutable.ImmutableDictionary`2.get_Item(TKey key)
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.HandleRenamedItems(IProjectTree tree, IImmutableDictionary`2 changeMap, IProjectChangeDescription change, IImmutableDictionary`2 projectData, HashSet`1 dynamicDependentChildrenAffected, ConfiguredProjectExports configuredProjectExports)
at Microsoft.VisualStudio.ProjectSystem.Designers.PhysicalProjectTreeProvider.OnProjectSubscriptionChanged(IProjectTree originalTree, ConfiguredProjectExports configuredProjectExports, PhysicalProjectTreeInputData updateInput, CancellationToken cancellationToken)
<---
~I am wondering, could it be that at project creation time, as my targets are being installed via nuget, could it be that VS can't add the file because the item type isn't known yet? I am clutching at straws here.~ After i tidied up my rule file (some of the properties were tied to an invalid ItemType.), in combination with not using the same value for the ItemType name and the ContentType name (I now use DnnManifest for the content type, and DnnManifestFile for the ItemType - this exception goes away.
Leaving this issue open because I think a more helpful exception message would be in order here, i.e what is the key that couldn't be added?)
I am glad that you managed to find a way to avoid the problem.
I agree, improving logging could make help investigate such issues.
Renaming the issue to reflect that.
in my vstemplate file, for my project template, I decided to add an extra item:
In ProjectItemsSchema.xaml
and the rule:
This rule is included in my custom targets file:
In my project template, in the project file:
The idea being that when the project is created, the "manifest.dnn" file will automatically be included in the project, with a "DnnManifest" item type.
However one important point, is that my custom project targets are added via a nuget install step in the vstemplate:
The issue is, when I create the project, the manifest file is not added, and I get an error window displayed, saying an error was logged. Looking at the log I see this:
~I am wondering, could it be that at project creation time, as my targets are being installed via nuget, could it be that VS can't add the file because the item type isn't known yet? I am clutching at straws here.~ After i tidied up my rule file (some of the properties were tied to an invalid ItemType.), in combination with not using the same value for the ItemType name and the ContentType name (I now use
DnnManifest
for the content type, andDnnManifestFile
for the ItemType - this exception goes away.Leaving this issue open because I think a more helpful exception message would be in order here, i.e what is the key that couldn't be added?)