OYIon / LiveSharp

Public repository for the LiveSharp project
96 stars 4 forks source link

Unloaded project are still scanned by livesharp #114

Closed pwhsoft closed 3 years ago

pwhsoft commented 3 years ago

It happens that I unload some projects in the Solution. If I then perform a cleanup of the solution and start my other project, the following message appears:

So i unloaded project 1 Cleanup Started project 2 Error occurs...

 Compilation failed:
System.IO.FileNotFoundException: Could not find file 'D:\Projekte\path\obj\Debug\netcoreapp3.1\TestWebsite1.dll'.
File name: 'D:\Projekte\path\obj\Debug\netcoreapp3.1\TestWebsite1.dll'
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at Roslyn.Utilities.FileUtilities.OpenFileStream(String path)
   at Microsoft.CodeAnalysis.MetadataReference.CreateFromFile(String path, MetadataReferenceProperties properties, DocumentationProvider documentation)
   at LiveSharp.RazorBuildEngine.<>c__DisplayClass7_0.<.ctor>b__4(RazorProjectEngineBuilder builder)
   at Microsoft.AspNetCore.Razor.Language.RazorProjectEngine.Create(RazorConfiguration configuration, RazorProjectFileSystem fileSystem, Action`1 configure)
   at LiveSharp.RazorBuildEngine..ctor(Project project, ConcurrentDictionary`2 additionalSettings, ILogger logger)
   at LiveSharp.RazorHandler..ctor(Solution solution, ConcurrentDictionary`2 additionalSettings, ILogger logger)
   at LiveSharp.LiveSharpWorkspace.LoadSolution(String nugetPath, String solutionPath, String projectDir, String projectName, Boolean needWatcherSubscribe)
server: 1.7.2.0
ionoy commented 3 years ago

LiveSharp doesn't know what projects are unloaded in the IDE because, to my knowledge, it's not reflected in the project system.

Maybe there could be a solution-specific configuration, but it seems like it would take less effort to just define LIVESHARP_DISABLE for the unloaded project.