ardalis / CleanArchitecture

Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core
MIT License
15.28k stars 2.67k forks source link

Failing Test : Cannot find reference assembly 'dotnet-aspnet-codegenerator-design.dll' #12

Closed divinci closed 6 years ago

divinci commented 6 years ago

Hi Ardalis,

Firstly a great project, lots of thought has gone into it I can see.

I simply fresh cloned, built, and run all tests. There is a single failed test.

I will find a workaround, I think removing Microsoft.VisualStudio.Web.CodeGeneration/ors but wanted to let you know.

Test Name:  CleanArchitecture.Tests.Integration.Web.HomeControllerIndexShould.ReturnViewWithCorrectMessage
Test FullName:  CleanArchitecture.Tests.Integration.Web.HomeControllerIndexShould.ReturnViewWithCorrectMessage
Test Source:    C:\repos\nbegvso\CleanArchitecture\tests\CleanArchitecture.Tests\Integration\Web\HomeControllerIndexShould.cs : line 10
Test Outcome:   Failed
Test Duration:  0:00:13.428

Result StackTrace:  
at Microsoft.Extensions.DependencyModel.Resolution.ReferenceAssemblyPathResolver.TryResolveAssemblyPaths(CompilationLibrary library, List'1 assemblies)
   at Microsoft.Extensions.DependencyModel.Resolution.CompositeCompilationAssemblyResolver.TryResolveAssemblyPaths(CompilationLibrary library, List'1 assemblies)
   at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths(ICompilationAssemblyResolver resolver, List'1 assemblies)
   at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
   at Microsoft.AspNetCore.Mvc.ApplicationParts.AssemblyPart.<>c.<GetReferencePaths>b__8_0(CompilationLibrary library)
   at System.Linq.Enumerable.SelectManySingleSelectorIterator'2.MoveNext()
   at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(IEnumerable'1 parts, MetadataReferenceFeature feature)
   at Microsoft.AspNetCore.Mvc.ApplicationParts.ApplicationPartManager.PopulateFeature[TFeature](TFeature feature)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.GetCompilationReferences()
   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func'1 valueFactory)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorReferenceManager.get_CompilationReferences()
   at Microsoft.AspNetCore.Mvc.Razor.Internal.LazyMetadataReferenceFeature.get_References()
   at Microsoft.CodeAnalysis.Razor.CompilationTagHelperFeature.GetDescriptors()
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorTagHelperBinderPhase.ExecuteCore(RazorCodeDocument codeDocument)
   at Microsoft.AspNetCore.Razor.Language.RazorEnginePhaseBase.Execute(RazorCodeDocument codeDocument)
   at Microsoft.AspNetCore.Razor.Language.DefaultRazorEngine.Process(RazorCodeDocument document)
   at Microsoft.AspNetCore.Razor.Language.RazorTemplateEngine.GenerateCode(RazorCodeDocument codeDocument)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(String relativePath)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CreateCacheEntry(String normalizedPath)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult()
   at Microsoft.AspNetCore.Mvc.Razor.Internal.DefaultRazorPageFactoryProvider.CreateFactory(String relativePath)
   at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.CreateCacheResult(HashSet'1 expirationTokens, String relativePath, Boolean isMainPage)
   at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.OnCacheMiss(ViewLocationExpanderContext expanderContext, ViewLocationCacheKey cacheKey)
   at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.LocatePageFromViewLocations(ActionContext actionContext, String pageName, Boolean isMainPage)
   at Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage)
   at Microsoft.AspNetCore.Mvc.ViewEngines.CompositeViewEngine.FindView(ActionContext context, String viewName, Boolean isMainPage)
   at Microsoft.AspNetCore.Mvc.ViewFeatures.Internal.ViewResultExecutor.FindView(ActionContext actionContext, ViewResult viewResult)
   at Microsoft.AspNetCore.Mvc.ViewResult.<ExecuteResultAsync>d__26.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeResultAsync>d__19.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResultFilterAsync>d__24.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResultExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextResourceFilter>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeFilterPipelineAsync>d__17.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeAsync>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.<Invoke>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIIndexMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Hosting.Internal.RequestServicesContainerMiddleware.<Invoke>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.TestHost.ClientHandler.<>c__DisplayClass3_0.<<SendAsync>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.TestHost.ClientHandler.<SendAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable'1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter'1.GetResult()
   at CleanArchitecture.Tests.Integration.Web.HomeControllerIndexShould.<ReturnViewWithCorrectMessage>d__0.MoveNext() in C:\repos\nbegvso\CleanArchitecture\tests\CleanArchitecture.Tests\Integration\Web\HomeControllerIndexShould.cs:line 11
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Result Message: System.InvalidOperationException : Cannot find reference assembly 'dotnet-aspnet-codegenerator-design.dll' file for package dotnet-aspnet-codegenerator-design
ardalis commented 6 years ago

I just did a fresh clone/build/test and everything works. Here's my output. Do you see anything that will help you? Do you have SDK 2.x installed?

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

PS C:\dev\scratch> git clone https://github.com/ardalis/cleanarchitecture
Cloning into 'cleanarchitecture'...
remote: Counting objects: 648, done.
remote: Compressing objects: 100% (38/38), done.
remote: Total 648 (delta 14), reused 29 (delta 5), pack-reused 603 eceiving objects:  94% (610/648)
Receiving objects: 100% (648/648), 722.88 KiB | 2.56 MiB/s, done.
Resolving deltas: 100% (308/308), done.
PS C:\dev\scratch> cd .\cleanarchitecture\
PS C:\dev\scratch\cleanarchitecture> ls

    Directory: C:\dev\scratch\cleanarchitecture

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----         5/1/2018  10:29 AM                src
d-----         5/1/2018  10:29 AM                tests
-a----         5/1/2018  10:29 AM           4444 .gitignore
-a----         5/1/2018  10:29 AM           6050 CleanArchitecture.sln
-a----         5/1/2018  10:29 AM           1089 LICENSE
-a----         5/1/2018  10:29 AM           8673 README.md

PS C:\dev\scratch\cleanarchitecture> dotnet build

Welcome to .NET Core!
---------------------
Learn more about .NET Core @ https://aka.ms/dotnet-docs. Use dotnet --help to see available commands or go to https://aka.ms/dotnet-cli-docs.

Telemetry
--------------
The .NET Core tools collect usage data in order to improve your experience. The data is anonymous and does not include command-line arguments. The data is collected by Microsoft and shared with the community.
You can opt out of telemetry by setting a DOTNET_CLI_TELEMETRY_OPTOUT environment variable to 1 using your favorite shell.
You can read more about .NET Core tools telemetry @ https://aka.ms/dotnet-cli-telemetry.
Microsoft (R) Build Engine version 15.7.163.20755 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests\CleanArchitecture.Tests.csproj...
  Restoring packages for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj...
  Restoring packages for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Web\CleanArchitecture.Web.csproj...
  Restoring packages for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Core\CleanArchitecture.Core.csproj...
  Generating MSBuild file C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Core\obj\CleanArchitecture.Core.csproj.nuget.g.props.
  Generating MSBuild file C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Core\obj\CleanArchitecture.Core.csproj.nuget.g.targets.
  Restore completed in 211.89 ms for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Core\CleanArchitecture.Core.csproj.
  Restore completed in 24.28 ms for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj.
  Restore completed in 7.91 ms for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Web\CleanArchitecture.Web.csproj.
  Restore completed in 30.42 ms for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Web\CleanArchitecture.Web.csproj.
  Restore completed in 27.29 ms for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Web\CleanArchitecture.Web.csproj.
  Restore completed in 12.93 ms for C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests\CleanArchitecture.Tests.csproj.
  Restoring packages for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj...
  Restore completed in 762.26 ms for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj.
  Restore completed in 13.87 ms for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj.
  Generating MSBuild file C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\obj\CleanArchitecture.Infrastructure.csproj.nuget.g.props.
  Generating MSBuild file C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\obj\CleanArchitecture.Infrastructure.csproj.nuget.g.targets.
  Restore completed in 3.24 sec for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\CleanArchitecture.Infrastructure.csproj.
  Installing Swashbuckle.AspNetCore.SwaggerUI 2.2.0.
  Installing Swashbuckle.AspNetCore.Swagger 2.2.0.
  Installing Swashbuckle.AspNetCore.SwaggerGen 2.2.0.
  Installing Swashbuckle.AspNetCore 2.2.0.
  Generating MSBuild file C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Web\obj\CleanArchitecture.Web.csproj.nuget.g.props.
  Generating MSBuild file C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Web\obj\CleanArchitecture.Web.csproj.nuget.g.targets.
  Restore completed in 3.88 sec for C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Web\CleanArchitecture.Web.csproj.
  Installing Microsoft.TestPlatform.ObjectModel 15.6.1.
  Installing Microsoft.TestPlatform.TestHost 15.6.1.
  Installing Microsoft.NET.Test.Sdk 15.6.1.
  Installing Moq 4.8.2.
  Generating MSBuild file C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests\obj\CleanArchitecture.Tests.csproj.nuget.g.props.
  Generating MSBuild file C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests\obj\CleanArchitecture.Tests.csproj.nuget.g.targets.
  Restore completed in 5.47 sec for C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests\CleanArchitecture.Tests.csproj.
  CleanArchitecture.Core -> C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Core\bin\Debug\netstandard2.0\CleanArchitecture.Core.dll
  CleanArchitecture.Infrastructure -> C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Infrastructure\bin\Debug\netcoreapp2.0\CleanArchitecture.Infrastructure.dll
  CleanArchitecture.Web -> C:\dev\scratch\cleanarchitecture\src\CleanArchitecture.Web\bin\Debug\netcoreapp2.0\CleanArchitecture.Web.dll
  CleanArchitecture.Tests -> C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests\bin\Debug\netcoreapp2.0\CleanArchitecture.Tests.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:17.36
PS C:\dev\scratch\cleanarchitecture> cd .\tests\CleanArchitecture.Tests\
PS C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests> dotnet test
Build started, please wait...
Build completed.

Test run for C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests\bin\Debug\netcoreapp2.0\CleanArchitecture.Tests.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 15.7.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Total tests: 7. Passed: 7. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 6.9940 Seconds
PS C:\dev\scratch\cleanarchitecture\tests\CleanArchitecture.Tests> dotnet --version
2.1.200-preview-007576
divinci commented 6 years ago

Hi @ardalis thanks for looking - I didn't have time to follow up with a more in depth investigation - However I have just tried with a clean VS Preview 15.7.0 Preview 5 and all is well now - closing the issue.