Restore-on-build for Blend fails first time, succeeds second time (VS scenario fixed) #2121

Closed
drewgillies opened this Issue Feb 16, 2016 · 9 comments

Comments

@drewgillies
Contributor

drewgillies commented Feb 16, 2016

Repro:

  1. Create UWP project in Blend/VSWinExpress
  2. Add a UWP Win2D NuGet package using the package manager
  3. Close Blend/VSWinExpress
  4. Go to %userprofile%.nuget\packages and delete Win2D.uwp
  5. Open Blend/VSWinExpress and reload project
  6. Build. No restore takes place and build fails.
  7. Build again. Restore takes place and build succeeds.

Also tracked in internal bug # 194090

@emgarten

This comment has been minimized.

Show comment
Hide comment
@emgarten

emgarten Feb 16, 2016

Contributor

What version of NuGet and Visual Studio is this using?

Contributor

emgarten commented Feb 16, 2016

What version of NuGet and Visual Studio is this using?

@drewgillies

This comment has been minimized.

Show comment
Hide comment
@drewgillies

drewgillies Feb 16, 2016

Contributor

This is VS 2015 Update 1 and NuGet version 167 (RTM).

Contributor

drewgillies commented Feb 16, 2016

This is VS 2015 Update 1 and NuGet version 167 (RTM).

@deepakaravindr

This comment has been minimized.

Show comment
Hide comment
@deepakaravindr

deepakaravindr Feb 17, 2016

Member

The issue occurs in one of the recent NuGet builds 3.4.0.632 as well. I have only tried Blend 14.0.24706.00 Update 1. I have not tried out VSWinExpress.

Note that the issue only occurs if NuGet has not already been loaded in the context of current Blend instance. This means that if NuGet Package Manager Console was already open in Repro step (5) or was opened before Repro step (6), then the issue will not occur.

Context:

  1. NuGet registers for Auto Loading of the NuGet VSIX by registering for VSConstants.UICONTEXT.SolutionBuilding_string. This means that NuGet VSIX is loaded in the VS or Blend instance when a solution/project is being built if it is not already loaded.
  2. NuGet also registers for _dte.Events.BuildEvents.OnBuildBegin event. This means that NuGet can restore packages as needed when a solution/project is being built.

Observation:

On a freshly opened instance where NuGet has not been loaded yet (not used in any way), when one opens a solution and performs a build

  1. VS raises event (1) above to load NuGet VSIX and lets it initialize fully before raising event (2), the OnBuildBegin event, to let NuGet restore packages if needed.
  2. However, Blend either raises (2) before (1) or processes (1) and (2) in parallel. Because, NuGet does not get the OnBuildBegin event the first time when the event to load the NuGet VSIX is raised. Once NuGet has been loaded, the OnBuildBegin event is raised properly and NuGet restores packages fine. This is the problem.

Should not Blend behave in the same way as VS to raise OnBuildBegin event after the registrations for VSConstants.UICONTEXT.SolutionBuilding_string are processed?

Member

deepakaravindr commented Feb 17, 2016

The issue occurs in one of the recent NuGet builds 3.4.0.632 as well. I have only tried Blend 14.0.24706.00 Update 1. I have not tried out VSWinExpress.

Note that the issue only occurs if NuGet has not already been loaded in the context of current Blend instance. This means that if NuGet Package Manager Console was already open in Repro step (5) or was opened before Repro step (6), then the issue will not occur.

Context:

  1. NuGet registers for Auto Loading of the NuGet VSIX by registering for VSConstants.UICONTEXT.SolutionBuilding_string. This means that NuGet VSIX is loaded in the VS or Blend instance when a solution/project is being built if it is not already loaded.
  2. NuGet also registers for _dte.Events.BuildEvents.OnBuildBegin event. This means that NuGet can restore packages as needed when a solution/project is being built.

Observation:

On a freshly opened instance where NuGet has not been loaded yet (not used in any way), when one opens a solution and performs a build

  1. VS raises event (1) above to load NuGet VSIX and lets it initialize fully before raising event (2), the OnBuildBegin event, to let NuGet restore packages if needed.
  2. However, Blend either raises (2) before (1) or processes (1) and (2) in parallel. Because, NuGet does not get the OnBuildBegin event the first time when the event to load the NuGet VSIX is raised. Once NuGet has been loaded, the OnBuildBegin event is raised properly and NuGet restores packages fine. This is the problem.

Should not Blend behave in the same way as VS to raise OnBuildBegin event after the registrations for VSConstants.UICONTEXT.SolutionBuilding_string are processed?

@deepakaravindr

This comment has been minimized.

Show comment
Hide comment
@deepakaravindr

deepakaravindr Feb 18, 2016

Member

FYI, I tried VSWinExpress and VSWebExpress

  1. Same issue was observed with VSWinExpress UAP application.
  2. On VSWebExpress, classic ClassLibrary project was able to restore packages to packages folder on the first build.
Member

deepakaravindr commented Feb 18, 2016

FYI, I tried VSWinExpress and VSWebExpress

  1. Same issue was observed with VSWinExpress UAP application.
  2. On VSWebExpress, classic ClassLibrary project was able to restore packages to packages folder on the first build.
@yishaigalatzer

This comment has been minimized.

Show comment
Hide comment
@yishaigalatzer

yishaigalatzer Mar 7, 2016

We figured out this is not a NuGet issue, but a visual studio core issue.

We figured out this is not a NuGet issue, but a visual studio core issue.

@dtivel dtivel modified the milestones: 3.6 Beta2, 3.4 RTM Sep 14, 2016

@dtivel dtivel reopened this Sep 14, 2016

@rrelyea rrelyea modified the milestones: 3.6 Beta1, 3.6 Beta2 Sep 21, 2016

@rrelyea rrelyea modified the milestones: 3.6 Beta1, 3.6 Beta2 Sep 22, 2016

@rrelyea rrelyea changed the title from Restore-on-build for non devenv exes fails first time, succeeds second time. to Restore-on-build for VS fails first time, succeeds second time Oct 18, 2016

alpaix added a commit to alpaix/NuGet.Client that referenced this issue Oct 19, 2016

[WIP] NRM Background Auto-Restore
Implementing solution auto-restore feature needed for CPS w/package-refs
 project system.

Created `SolutionRestoreWorker` singleton class responsible for running
 solution restore jobs in VS. It supports two methods of running restore.
 The blocking restore is invoked on-build or via context menu. Background
 restore is scheduled vis Nominate API.

Original `OnBuildRestorer` class was decomposed into `SolutionRestoreJob`
 and `WaitDialogLogger`.

The `RestoreManagerPackage` was moved out of `VsExtension` project and
 is now configured to auto-load on solution open and start listening to
 build events.

Fixes NuGet/Home#3657, NuGet/Home#2121.

@alpaix alpaix referenced this issue in NuGet/NuGet.Client Oct 19, 2016

Closed

[WIP] NRM Background Auto-Restore #944

alpaix added a commit to alpaix/NuGet.Client that referenced this issue Oct 20, 2016

NRM Background Auto-Restore
Implementing solution auto-restore feature needed for CPS w/package-refs
 project system.

Created `SolutionRestoreWorker` singleton class responsible for running
 solution restore jobs in VS. It supports two methods of running restore.
 The blocking restore is invoked on-build or via context menu. Background
 restore is scheduled vis Nominate API.

Original `OnBuildRestorer` class was decomposed into `SolutionRestoreJob`
 and `WaitDialogLogger`.

The `RestoreManagerPackage` was moved out of `VsExtension` project and
 is now configured to auto-load on solution open and start listening to
 build events.

Fixes NuGet/Home#3657, NuGet/Home#2121.

alpaix added a commit to alpaix/NuGet.Client that referenced this issue Oct 20, 2016

NRM Background Auto-Restore
Implementing solution auto-restore feature needed for CPS w/package-refs
 project system.

Created `SolutionRestoreWorker` singleton class responsible for running
 solution restore jobs in VS. It supports two methods of running restore.
 The blocking restore is invoked on-build or via context menu. Background
 restore is scheduled vis Nominate API.

Original `OnBuildRestorer` class was decomposed into `SolutionRestoreJob`
 and `WaitDialogLogger`.

The `RestoreManagerPackage` was moved out of `VsExtension` project and
 is now configured to auto-load on solution open and start listening to
 build events.

Fixes NuGet/Home#3657, NuGet/Home#2121.

alpaix added a commit to NuGet/NuGet.Client that referenced this issue Oct 21, 2016

NRM Background Auto-Restore
Implementing solution auto-restore feature needed for CPS w/package-refs
 project system.

Created `SolutionRestoreWorker` singleton class responsible for running
 solution restore jobs in VS. It supports two methods of running restore.
 The blocking restore is invoked on-build or via context menu. Background
 restore is scheduled vis Nominate API.

Original `OnBuildRestorer` class was decomposed into `SolutionRestoreJob`
 and `WaitDialogLogger`.

The `RestoreManagerPackage` was moved out of `VsExtension` project and
 is now configured to auto-load on solution open and start listening to
 build events.

Fixes NuGet/Home#3657, NuGet/Home#2121.
@rrelyea

This comment has been minimized.

Show comment
Hide comment
@rrelyea

rrelyea Oct 27, 2016

Contributor

Appears fixed. However in my repro (on a VM), VS was black, and dialog was showing. Please see what you see.

Contributor

rrelyea commented Oct 27, 2016

Appears fixed. However in my repro (on a VM), VS was black, and dialog was showing. Please see what you see.

@rrelyea rrelyea assigned mishra14 and unassigned alpaix Oct 27, 2016

@mishra14

This comment has been minimized.

Show comment
Hide comment
@mishra14

mishra14 Oct 27, 2016

Contributor

@rrelyea : Seems to be fixed in VS 2017 build d15prerel/15.0.25826.3

Validating on Blend,

Contributor

mishra14 commented Oct 27, 2016

@rrelyea : Seems to be fixed in VS 2017 build d15prerel/15.0.25826.3

Validating on Blend,

@mishra14

This comment has been minimized.

Show comment
Hide comment
@mishra14

mishra14 Oct 28, 2016

Contributor

Investigated more on blend. Seems like NRM is either not being loaded or Blend/VS platform does not fire the right events. Will investigate further.

Contributor

mishra14 commented Oct 28, 2016

Investigated more on blend. Seems like NRM is either not being loaded or Blend/VS platform does not fire the right events. Will investigate further.

@rrelyea rrelyea changed the title from Restore-on-build for VS fails first time, succeeds second time to Restore-on-build for Blend fails first time, succeeds second time (VS scenario fixed) Oct 28, 2016

@rrelyea rrelyea modified the milestones: 4.0 RC2, 4.0 RC Oct 28, 2016

@rrelyea rrelyea modified the milestones: 4.0 RC2, 4.0 RC3 Nov 29, 2016

@rrelyea

This comment has been minimized.

Show comment
Hide comment
@rrelyea

rrelyea Dec 1, 2016

Contributor

will be fixed by blend team RC2 fix for Bug 297804:NuGet badly broken in blend since NuGet.SolutionRestoreManager (a new pkgdef in RC1), cannot be loaded

Contributor

rrelyea commented Dec 1, 2016

will be fixed by blend team RC2 fix for Bug 297804:NuGet badly broken in blend since NuGet.SolutionRestoreManager (a new pkgdef in RC1), cannot be loaded

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