New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gulp NuGet Restore no longer working [v9] #422

Closed
derekcorreia opened this Issue Jul 6, 2018 · 9 comments

Comments

Projects
3 participants
@derekcorreia
Collaborator

derekcorreia commented Jul 6, 2018

Unclear now if this is environmental, but running the gulp task after install isn't working. The Nuget-Restore task "runs", but no assemblies get restored.

Sitecore Version
v9 Branch (9.0.2)

To Reproduce

  1. Install Habitat via instructions (install-xp0.ps1)
  2. In elevated PS window, run npm install from root directory.
  3. Run Gulp

Expected behavior
Habitat builds and deploys.

Snip of my output showing the quick autorun of Nuget-Restore, which doesn't restore packages:

PS C:\projects\Habitat> gulp
[12:06:15] O---o   _____ _ _                            _   _      _ _
[12:06:15]  O-o   /  ___(_) |                          | | | |    | (_)
[12:06:15]   O    \ `--. _| |_ ___  ___ ___  _ __ ___  | |_| | ___| |___  __
[12:06:15]  o-O    `--. \ | __/ _ \/ __/ _ \| '__/ _ \ |  _  |/ _ \ | \ \/ /
[12:06:15] o---O  /\__/ / | ||  __/ (_| (_) | | |  __/ | | | |  __/ | |>  <
[12:06:15] O---o  \____/|_|\__\___|\___\___/|_|  \___| \_| |_/\___|_|_/_/\_\
[12:06:15]  O-o
[12:06:15]   O    -------------------- helix.sitecore.net ------------------
[12:06:15]  o-O
[12:06:15] o---O  The Habitat source code, tools and processes are examples of Sitecore Helix.
[12:06:15] O---o  Habitat is not supported by Sitecore and should be used at your own risk.
[12:06:15]  O-o
[12:06:15]   O    ----------------------------------------------------------
[12:06:15]  o-O
[12:06:15] o---O
[12:06:15] Using gulpfile C:\projects\Habitat\gulpfile.js
[12:06:15] Starting 'default'...
[12:06:15] Starting 'Copy-Sitecore-License'...
Copying Sitecore License file
[12:06:15] Finished 'Copy-Sitecore-License' after 45 ms
[12:06:15] Starting 'Copy-Sitecore-Lib'...
Copying Sitecore Libraries
[12:06:18] Finished 'Copy-Sitecore-Lib' after 2.99 s
[12:06:18] Starting 'Nuget-Restore'...
[12:06:19] MSBuild auto-detection: using msbuild version '4.0' from 'C:\Windows\Microsoft.NET\Framework\v4.0.30319'.

[12:06:19] Finished 'Nuget-Restore' after 871 ms
[12:06:19] Starting 'Publish-All-Projects'...
[12:06:19] Starting 'Build-Solution'...
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2041,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Webpages". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get
compilation errors. [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2041,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Webpages.Deployment". Check to make sure the assembly exists on disk. If this reference is required by your code, y
ou may get compilation errors. [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2041,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Webpages.Razor". Check to make sure the assembly exists on disk. If this reference is required by your code, you ma
y get compilation errors. [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\Microsoft.Common.CurrentVersion.targets(2041,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.Web.Helpers". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get c
ompilation errors. [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
ServiceCollectionExtensions.cs(7,18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
ServiceCollectionExtensions.cs(8,17): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
ServiceCollectionExtensions.cs(13,20): error CS0234: The type or namespace name 'Diagnostics' does not exist in the namespace 'Sitecore' (are you missing an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
Infrastructure\MvcControllerServicesConfigurator.cs(3,21): error CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
Infrastructure\MvcControllerServicesConfigurator.cs(4,20): error CS0234: The type or namespace name 'DependencyInjection' does not exist in the namespace 'Sitecore' (are you missing an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
Infrastructure\MvcControllerServicesConfigurator.cs(6,54): error CS0246: The type or namespace name 'IServicesConfigurator' could not be found (are you missing a using directive or an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
Infrastructure\MvcControllerServicesConfigurator.cs(8,31): error CS0246: The type or namespace name 'IServiceCollection' could not be found (are you missing a using directive or an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
ServiceCollectionExtensions.cs(19,64): error CS0246: The type or namespace name 'IServiceCollection' could not be found (are you missing a using directive or an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]
ServiceCollectionExtensions.cs(24,64): error CS0246: The type or namespace name 'IServiceCollection' could not be found (are you missing a using directive or an assembly reference?) [C:\projects\Habitat\src\Foundation\DependencyInjection\code\Sitecore.Foundation.DependencyInjection.csproj]

@nickwesselman nickwesselman added the v9 label Jul 6, 2018

@nickwesselman nickwesselman added this to To do in Release for Sitecore 9.0 via automation Jul 6, 2018

@nickwesselman

This comment has been minimized.

Collaborator

nickwesselman commented Jul 6, 2018

Yeah this repros for me as well, probably related to the move to PackageReference. I tried updating gulp-nuget-restore to 0.6.0 and that doesn't seem to solve the problem. Seems like it's still picking up the wrong version of MSBuild. You can do a nuget restore in Visual Studio as a workaround.

@jeanfrancoislarente do you have this issue in Habitat.Home??

@jeanfrancoislarente

This comment has been minimized.

Collaborator

jeanfrancoislarente commented Jul 6, 2018

@nickwesselman - I updated mine to "gulp-nuget-restore": "^0.6.0" and "gulp-msbuild": "^0.5.5"

@jeanfrancoislarente

This comment has been minimized.

Collaborator

jeanfrancoislarente commented Jul 6, 2018

(In HabitatHome.Content) - didn't have the issue locally when I tested the changes.

@nickwesselman

This comment has been minimized.

Collaborator

nickwesselman commented Jul 6, 2018

I think this might be an issue with what msbuild is in your PATH. To avoid the issue altogether, we can get rid of Nuget-Restore and use the new /restore flag w/ the msbuild call:
Microsoft/msbuild#2414

@derekcorreia

This comment has been minimized.

Collaborator

derekcorreia commented Jul 6, 2018

Thanks @jeanfrancoislarente , upping to those versions works in grabbing the references, but throws these errors for each NuGet package:

Unable to resolve 'C:\projects\Habitat\src\Foundation\SitecoreExtensions\code\Sitecore.Foundation.SitecoreExtensions.csproj' for '.NETFramework,Version=v4.6.2'.
Unable to resolve 'C:\projects\Habitat\src\Foundation\SitecoreExtensions\code\Sitecore.Foundation.SitecoreExtensions.csproj' for '.NETFramework,Version=v4.6.2 (win)'.
Unable to resolve 'C:\projects\Habitat\src\Foundation\SitecoreExtensions\code\Sitecore.Foundation.SitecoreExtensions.csproj' for '.NETFramework,Version=v4.6.2 (win-x64)'.
Unable to resolve 'C:\projects\Habitat\src\Foundation\SitecoreExtensions\code\Sitecore.Foundation.SitecoreExtensions.csproj' for '.NETFramework,Version=v4.6.2 (win-x86)'.

Doesn't appear that the packages for 9.0.2 are for 4.6.2 -- the packages themselves contain assemblies in NET452 folders.

@nickwesselman

This comment has been minimized.

Collaborator

nickwesselman commented Jul 6, 2018

Sitecore 9 definitely should be targeting Framework 4.6.2:
https://kb.sitecore.net/articles/087164

I'm not getting those errors, hold tight as I'm committing a fix for the restore shortly that hopefully solves things. Can you confirm you are on MSBuild 15.5 or higher? If not you may need to update VS17.

@derekcorreia

This comment has been minimized.

Collaborator

derekcorreia commented Jul 6, 2018

@nickwesselman those errors go away with your suggestion of moving to the restore switch. I'm on 15.5/VS17.

After changing the build definition to the following and removing the nuget-restore step from the default gulp task, the solution properly restores nuget packages:

gulp.task("Build-Solution",
    function() {
        var targets = ["Build"];
        if (config.runCleanBuilds) {
            targets = ["Clean", "Build"];
        }

        var solution = "./" + config.solutionName + ".sln";
        return gulp.src(solution)
            .pipe(msbuild({
                targets: targets,
                configuration: config.buildConfiguration,
                logCommand: false,
                verbosity: config.buildVerbosity,
                stdout: true,
                errorOnFail: true,
                maxcpucount: config.buildMaxCpuCount,
                nodeReuse: false,
                toolsVersion: config.buildToolsVersion,
                customArgs: ['/restore'],
                properties: {
                    Platform: config.buildPlatform
                }
            }));
    });

However, there are new errors. Safe to close this issue and open new ones for the resulting issues, I think.

@nickwesselman

This comment has been minimized.

Collaborator

nickwesselman commented Jul 6, 2018

@derekcorreia Are the new errors with System.Web.Mvc on some of the test projects? Issuing PR now

nickwesselman added a commit that referenced this issue Jul 6, 2018

[#422] Fixes for PackageReference conversion
* update mechanism of restoring nuget packages to avoid finding wrong MSBuild
* Fix System.Web.Mvc references on some test projects to PackageReference

nickwesselman added a commit that referenced this issue Jul 6, 2018

[#422] More Assembly Reference Cleanup
* Some MVC and other references were still pointed at Packages folder
* There were also lots of broken references to libs folder that didn't seem to be needed

@nickwesselman nickwesselman self-assigned this Jul 6, 2018

@nickwesselman nickwesselman moved this from To do to In progress in Release for Sitecore 9.0 Jul 6, 2018

nickwesselman added a commit that referenced this issue Jul 6, 2018

Merge pull request #423 from Sitecore/issue/422/nuget-fixes
[#422] Fixes for PackageReference conversion
@derekcorreia

This comment has been minimized.

Collaborator

derekcorreia commented Jul 9, 2018

Validated this morning, no issues with build or gulp tasks. Closing.

Release for Sitecore 9.0 automation moved this from In progress to Done Jul 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment