question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RazorGenerator Extension uses hardcoded "SolutionName\ProjectName" path - causes exceptions when project is in a solution folder

See original GitHub issue

This 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:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
daipluspluscommented, Mar 2, 2017

I’ve made a fix for this issue and added a pull-request: https://github.com/RazorGenerator/RazorGenerator/pull/139

2reactions
foresightyjcommented, Nov 24, 2016

I experienced the same error. Wish this bug can be fixed soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The custom tool 'RazorGenerator' failed. The method or ...
I downloaded the source, built locally and copied the 'RazorGenerator.Core.v1.dll' into the directory from the error message but it still didn't ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found