dotnet / project-system

The .NET Project System for Visual Studio
MIT License
967 stars 386 forks source link

Project is not in loaded/ready state when creating ASP .Net Core project from template #1332

Closed ravipal closed 7 years ago

ravipal commented 7 years ago

As part of service fabric application creation, we create a ASP .Net Core project from template using below call. EnvDTE80.Solution2.AddFromTemplate(); This supposed to return the Project instance with the project tree loaded. But it returns null. Then we use dte.Solution.Projects to search by project name to get the project.

Later when we install NugetPackage (IVsPackageInstaller.InstallPackage) to the above project the installation fails with below exception. As per Nuget team, the failures is caused because the project is still not loaded

The operation failed as details for project Web1 could not be loaded.System.InvalidOperationException: The operation failed as details for project Web1 could not be loaded. at NuGet.PackageManagement.VisualStudio.CpsPackageReferenceProject.GetAssetsFilePathAsync() at NuGet.PackageManagement.NuGetPackageManager.d74.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) at NuGet.PackageManagement.NuGetPackageManager.d65.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.PackageManagement.NuGetPackageManager.d48.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.PackageManagement.NuGetPackageManager.d47.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.VisualStudio.VsPackageInstaller.d26.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at NuGet.VisualStudio.VsPackageInstaller.d25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at NuGet.VisualStudio.VsPackageInstaller.d__25.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread() at NuGet.VisualStudio.VsPackageInstaller.InstallPackage(String source, Project project, String packageId, String version, Boolean ignoreDependencies) at Microsoft.VisualStudio.Azure.Fabric.Shared.ServiceCreation.ServiceTemplateInterpreter.InstallNuGetPackages(IServiceProvider serviceProvider, Hierarchy project, ServiceTemplateServiceContentProjectPackage[] packages, String serviceId)Failed to install package 'Microsoft.ServiceFabric.Data':

Steps to repro:

  1. Install VS 2017 rel with workloads ‘ASP.NET and web development’ and ‘Azure development’
  2. Install Service Fabric Runtime \trinlab2\BAQAFiles\servicefabric\5.4\MicrosoftServiceFabric.5.4.145.9494.msi
  3. Install Service Fabric SDK \trinlab2\BAQAFiles\servicefabric\5.4\MicrosoftServiceFabricSDK.2.4.145.msi
  4. Copy the files from \scratch2\scratch\ravipal\projectNotLoaded* to C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\Extensions\Microsoft\Service Fabric Tools\
  5. Clear the MEF cache
  6. Create a new project file->new->Cloud->Service Fabric, choose the ASP.Net Core and create a web application. This will fail to install the Nuget package.
davkean commented 7 years ago

What am I missing, this looks like: https://github.com/NuGet/Home/issues/4253?

davkean commented 7 years ago

Are you saying that EnvDTE80.Solution2.AddFromTemplate returns null?

ravipal commented 7 years ago

The error message is similar to NuGet/Home#4253 but it is a different issue. Yes EnvDTE80.Solution2.AddFromTemplate returns null.

srivatsn commented 7 years ago

@ravipal is this blocking you for RTM? Let me know if I need to pull this back in to RTM.

ravipal commented 7 years ago

We have a workaround, so it is not blocking the RTM. But ideally, we would like to not have workaround, so if it feasible, please fix this in RTM.

NCarlsonMSFT commented 7 years ago

FYI EnvDTE80.Solution2.AddFromTemplate is supposed to return null for VB and C# projects. See the remarks in https://msdn.microsoft.com/en-us/library/behck2xd.aspx. Searching dte.Solution.Projects by project name is the documented solution.

davkean commented 7 years ago

Yeah good spot. Looking through the code it only returns a project when it's not a vstemplate/vsz.

Based on that and that the original NuGet issue is resolved, I'll close this.

ravipal commented 7 years ago

The issue was, after the call to AddFromTemplate(), the project is still not in loaded state as a result when we use nuget package installer, it fails because the project is not ready.

davkean commented 7 years ago

Which is different from https://github.com/NuGet/Home/issues/4253 how?