RazorGenerator Extension uses hardcoded "SolutionName\ProjectName" path - causes exceptions when project is in a solution folder
See original GitHub issueThis is a reposting of http://razorgenerator.codeplex.com/workitem/116 - because I’m experiencing the same issue.
My solution has an ASP.NET MVC project within a virtual solution folder while the .csproj
itself is under another directory.
So my Solution Explorer tree view looks like this:
+ "FooBar" (Solution node)
+ "Lorem Ipsum" (Solution folder)
+ "Qux" (ASP.NET Project)
+ View.cshtml
While my filesystem tree is this:
/foobar.sln
baz/
qux/
qux.csproj
View.cshtml
When I run Enable-RazorGenerator
for the first time in the Package Manager Console I get this exception message repeated for each *.cshtml
file in the project:
PM> Enable-RazorGenerator Exception calling “GetItem” with “1” argument(s): “Value does not fall within the expected range.” At C:\foobar\packages\RazorGenerator.Mvc.2.4.7\tools\RazorGenerator.psm1:63 char:21
+ ... $solutionExplorer.GetItem("$SolutionName\$ProjectName$rel ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentException
The bug is indeed here: https://github.com/RazorGenerator/RazorGenerator/blob/master/RazorGenerator.Powershell/RazorGenerator.psm1 on line 63:
$solutionExplorer.GetItem("$SolutionName\$ProjectName$relativePath").UIHierarchyItems.Expanded = $false
$solutionExplorer.GetItem
corresponds to EnvDTE.UIHierarchy.GetItem(String names)
which requires a “tree path” as opposed to a filesystem path, however computing that path is complicated. I suspect a better approach might be to instead iterate through the UIHierarchy and then set its collapsed state if it’s a *.cshtml
file instead of using the same file-list from Get-ProjectFiles
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:6 (2 by maintainers)
Top GitHub Comments
I’ve made a fix for this issue and added a pull-request: https://github.com/RazorGenerator/RazorGenerator/pull/139
I experienced the same error. Wish this bug can be fixed soon.