MvcSiteMapProvider icon indicating copy to clipboard operation
MvcSiteMapProvider copied to clipboard

Unable to install on a new blank mvc4 project

Open farrukhsubhani opened this issue 11 years ago • 10 comments

I have updated all my packages on a blank project which did update Microsoft.AspNet.Razor to 3.0.0 and MVCSitemap helper is now failing on install due to it not being able to Update Razor 3.0.0 to 2.0.30506.0 saying:

Install-Package : Updating 'Microsoft.AspNet.Razor 3.0.0' to 'Microsoft.AspNet.Razor 2.0.30506.0' failed. Unable to find versions of 'Microsoft.AspNet.WebPages, Microsoft.AspNet. Mvc' that are compatible with 'Microsoft.AspNet.Razor 2.0.30506.0'.

farrukhsubhani avatar Nov 14 '13 02:11 farrukhsubhani

Are you sure it's an MVC4 project youare targeting? Looks like MVC5 from the errors.

maartenba avatar Nov 14 '13 08:11 maartenba

I have checked the values that are inserted into the .nuspec file and they are supposed to constrain the version of Razor to < 3.0.

<?xml version="1.0"?>
<!-- MvcSiteMapProvider.MVCx.Core shared Nuget specification file; all packages share this -->
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
    <metadata>
        <id>MvcSiteMapProvider.MVC4.Core</id>
        <title>MvcSiteMapProvider MVC4 Core</title>
        <version>$version$</version>
        <authors>Maarten Balliauw, Shad Storhaug</authors>
        <requireLicenseAcceptance>false</requireLicenseAcceptance>
        <summary>MvcSiteMapProvider is a tool that provides flexible menus, breadcrumb trails, and SEO features for the ASP.NET MVC framework, similar to the ASP.NET SiteMapProvider model. The project is hosted on http://github.com/maartenba/MvcSiteMapProvider.</summary>
        <description>This package contains only the core library for MvcSiteMapProvider. Use this package if you need to reference the library from a non-MVC project such as a class library.</description>
        <language>en-US</language>
        <tags>mvc mvc4 sitemap mvcsitemap menu breadcrumb navigation mvcsitemapprovider</tags>
        <projectUrl>http://github.com/maartenba/MvcSiteMapProvider</projectUrl>
        <iconUrl>http://download.codeplex.com/Project/Download/FileDownload.aspx?ProjectName=mvcsitemap&amp;DownloadId=196029</iconUrl>
        <dependencies>
            <group targetFramework="net35">
                <dependency id="Microsoft.AspNet.Razor" version="[2.0,3.0)"/>
                <dependency id="Microsoft.AspNet.WebPages" version="[2.0,3.0)"/>
                <dependency id="Microsoft.AspNet.Mvc" version="[4.0,5.0)"/>
            </group>
            <group targetFramework="net40">
                <dependency id="WebActivatorEx" version="2.0.1" />
                <dependency id="Microsoft.AspNet.Razor" version="[2.0,3.0)"/>
                <dependency id="Microsoft.AspNet.WebPages" version="[2.0,3.0)"/>
                <dependency id="Microsoft.AspNet.Mvc" version="[4.0,5.0)"/>
            </group>
            <group targetFramework="net45">
                <dependency id="WebActivatorEx" version="2.0.1" />
                <dependency id="Microsoft.AspNet.Razor" version="[2.0,3.0)"/>
                <dependency id="Microsoft.AspNet.WebPages" version="[2.0,3.0)"/>
                <dependency id="Microsoft.AspNet.Mvc" version="[4.0,5.0)"/>
            </group>
        </dependencies>
    </metadata>
</package>

The problem is Nuget doesn't respect this for package authors. I reported this bug to them and it looks like they are planning to fix this in 2.9 (which is due in January).

They did "fix' this for end users, but that ties our hands and puts the onus on you to fix it. Have a look at the Nuget documentation to see how to constrain versions - you will have to manually edit your packages.config file to do so.

NightOwl888 avatar Nov 14 '13 08:11 NightOwl888

BTW - Please "vote" the issue at Codeplex to help increase the priority. The more votes, the faster and more likely it is this issue will get fixed.

NightOwl888 avatar Nov 14 '13 08:11 NightOwl888

Oops - I misspoke. Version 2.8 is scheduled for January. Who knows when 2.9 will get released.

NightOwl888 avatar Nov 14 '13 08:11 NightOwl888

I have done couple of other tests on blank MVC4 project and

  • When adding to new MVC4 project because it has Microsoft.AspNet.Razor <3.0.0 it works great.
  • If you run update package or update Microsoft.AspNet.Razor it will be latest version which is greater than 3.0.0 and after this update i was not able to install

farrukhsubhani avatar Nov 14 '13 18:11 farrukhsubhani

Right. I saw on the NuGet site that they have already fixed it so it won't upgrade dependencies during an upgrade command in 2.8. However, there is nothing we can do to fix this except vote on the issue, as this is a problem with NuGet, not with our package.

However, in the meantime you can use the allowedVersions attribute to constrain the package to < 3.0. I haven't tested it, but I am hopeful that it works better than the one in the .nuspec file. The downside is that every installer of our package will need to update this manually in their packages.config file.

<?xml version="1.0" encoding="utf-8"?>
<packages>
    <package id="Microsoft.AspNet.Razor" version="2.0" allowedVersions="[2,3)" />
</packages>

This should prevent it from upgrading higher than 2.9.x when you manually upgrade MvcSiteMapProvider.

NightOwl888 avatar Nov 14 '13 19:11 NightOwl888

Does it have any known issues with Razor >3.0.0 or is there a version one can test with higher version of Razor?

farrukhsubhani avatar Nov 14 '13 19:11 farrukhsubhani

MvcSiteMapProvider works with Razor 3.0.0, but MVC 4 does not. The MvcSiteMapProvider.MVC5 package supports razor 3.0, but currently there is only support for MVC 5 in Visual Studio 2013. A VS 2012 update for MVC 5 is expected to be released by Microsoft within the coming weeks.

NightOwl888 avatar Nov 14 '13 19:11 NightOwl888

FYI - It is now possible to update VS 2012 so it will support MVC 5.

http://blogs.msdn.com/b/webdev/archive/2013/11/18/announcing-release-of-asp-net-and-web-tools-2013-1-for-visual-studio-2012.aspx

NightOwl888 avatar Nov 29 '13 05:11 NightOwl888

Thanks for letting me know. I was using a vm with 2013 but will run an update on actual system and test this.

farrukhsubhani avatar Nov 29 '13 05:11 farrukhsubhani