1

Reproduce:

In Visual Studio 2017, xUnit Test project:

Right-click Project, select Add -> New Item... Select 'Online'

Error dialog:

Retrieving Visual Studio 2017 online item templates fails with "'baseName' cannot be an empty string ("") or start with null character"

Parameter name: baseName

Log:

=====================
08/02/2018 10:36:14
Recoverable
System.ArgumentException: 'baseName' cannot be an empty string ("") or start with the null character.
Parameter name: baseName
   at Microsoft.Requires.NotNullOrEmpty(String value, String parameterName)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.SimpleHierarchyNode.<GenerateUniqueItemNameAsync>d__80.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.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass460_0.<<GenerateUniqueItemName>b__0>d.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 Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously(Func`1 asyncAction)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass548_0.<HrInvoke>b__0()
   at Microsoft.VisualStudio.ProjectSystem.VS.HResult.<>c__DisplayClass36_0.<Invoke>b__0()
   at Microsoft.VisualStudio.ProjectSystem.VS.HResult.Invoke(Func`1 action, IServiceProvider vsShellServiceProvider, IProjectFaultHandlerService projectFaultHandlerService, UnconfiguredProject project)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass6_0.<SubmitErrorReport>b__0()
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>b__0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
===================
08/02/2018 10:43:30
Recoverable
System.ArgumentException: 'baseName' cannot be an empty string ("") or start with the null character.
Parameter name: baseName
   at Microsoft.Requires.NotNullOrEmpty(String value, String parameterName)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.SimpleHierarchyNode.<GenerateUniqueItemNameAsync>d__80.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.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass460_0.<<GenerateUniqueItemName>b__0>d.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 Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously(Func`1 asyncAction)
   at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass548_0.<HrInvoke>b__0()
   at Microsoft.VisualStudio.ProjectSystem.VS.HResult.<>c__DisplayClass36_0.<Invoke>b__0()
   at Microsoft.VisualStudio.ProjectSystem.VS.HResult.Invoke(Func`1 action, IServiceProvider vsShellServiceProvider, IProjectFaultHandlerService projectFaultHandlerService, UnconfiguredProject project)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
   at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass6_0.<SubmitErrorReport>b__0()
   at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>b__0()
   at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
===================

Tried:

Solution in this answer (similar message, different cause):

Clearing NuGet cache, restarting

I can't find and information about this particular symptom-cause anywhere. I'm fairly new to VS, and to .NET in general so there might be helpful information in the log that I'm not understanding.

Bsquare ℬℬ
  • 4,423
  • 11
  • 24
  • 44
Rogue_Leader
  • 212
  • 3
  • 14
  • 1
    I have the same error but only on some of my projects. Must be a problem with the csproj file I guess. Try opening the dialogue on another project (type) and install the template from there. Sadly I don't know the exact cause myself yet – Patrick Braunstorfer Feb 08 '18 at 19:40
  • I tried this with a Console (as opposed to xUnit Test) type project and it solved it. Irrational behaviour, poor error message, but I suppose that's what to expect when dealing with MS tech. If you add this as an answer, I'll accept it. Thanks. – Rogue_Leader Feb 10 '18 at 14:27

1 Answers1

1

I ran into this same issue. Unfortunately it looks like a problem that Microsoft has to address. At the following URL it says they resolved it and will be including the fix in the next update: https://developercommunity.visualstudio.com/content/problem/192168/add-new-file-online-template-basename-empty-string.html

For now the workaround Patrick mentioned, adding from another project, is going to be your best bet.

Kris
  • 1,789
  • 3
  • 18
  • 27