Open VincentH-Net opened 6 years ago
This should have been fixed with the move to the external build agent, right? Have you encountered this issue anymore?
Today I updated the VSIX in VS2017, after that I got the same error. Exit and reopen VS, build, error gone.
But the injection is now handled by the BuildAgent process. How can it be the same error?
I meant not the first error in the issue but the second:
Sometimes after NuGet update this error occurs on build:
"LiveSharp.Runtime.dll wasn't found in obj\Debug"
This error also occurs when switching branches from a branch that does not have LiveSharp NuGet packages to one that does. Also here: close and reopen VS, then build again -> error gone
Oh, I've completely misunderstood the issue then!
I'm still looking for a proper solution to inject LiveSharp.Runtime.dll dependency. At the moment, I distribute the latest runtime with the extension. My goal is to not depend on NuGet for LiveSharp updates. Automatic extension updates would make it that the user doesn't have to think about LiveSharp at all (mostly). LiveSharp doesn't have an API that user code depends on, so "always updated" seems like a good strategy to me. I would even remove LiveSharp NuGet package completely. But I haven't found a way to make it work otherwise.
Considering the above, I need to copy the latest runtime assembly from extension installation folder to somewhere where building pipeline can predictably access it. Right now it's an IntermediateOutputPath
or obj
. But there are sometimes issues with locating this path from the VS extension. Also, I do not differentiate projects that don't even have LiveSharp installed into them. So runtime library gets copied in every project of the solution.
I could copy the runtime library to some global location, but I haven't found a good one yet.
Seems to me that as long as you cannot eliminate using a NuGet package, the simplest way is to include the DLL in the NuGet package. Better to use the standard approach to avoid issues until you have a complete alternative
PS having the NuGet package is no real burden for devs imo. We have to update NuGets all the time anyway, one more does not make a lot of difference
My point of view is that automatic updates would drastically improve the overall experience of using LiveSharp. Because even if the issue you are encountering is already fixed, you still spend some time googling the problem, remembering to update the package, etc. That adds to the frustration, which is undesirable.
With automatic updates, you should encounter fewer issues since you can't forget to update. With the problems you do face, you can directly go to the developer (me) or post on GitHub. I could even include that suggestion in the error message since it should be an exceptional case, not the norm.
Hi @ionoy, as you asked I found a repro for build failed with error
LiveSharp.Runtime.dll wasn't found
I suspect the same issue occurs when I switch from a branch with LiveSharp enabled to one with LiveSharp disabled and back.
Since deleting bin/obj is a common fix for Xamarin build problems I think it would be good if LiveSharp does not break the build after that.
Detailed steps I took:
VS 2017 v 15.9.11 + LiveSharp VSIX v 1.2.0 File | New Project | Mobile App (Xamarin.Forms) Blank, Android, Shared Project NuGet: Add LiveSharp Latest Stable 1.0.57
Shared Project:
using Xamarin.Forms;
namespace App1
{
public class MainPage : ContentPage
{
public MainPage() => Build();
void Build()
{
Content = new StackLayout
{
Children =
{
new Label { Text = "Hello World" }
}
};
}
}
}
Debug (on Android emulator) -> Page displays OK, no errors
Change label text, save -> page updates ok
Android project properties | switch to Release | Add LIVESHARP_DISABLE conditional compilation symbol | Build -> Build succeeds, no errors
Switch back to Debug, Debug on Android emulator -> Page displays OK, no errors
Change label text, save -> page updates ok
Android project: Clean, delete bin/obj, Debug
-> ERROR VS output: 1>(LiveSharpTask target) -> 1> C:\Users\Admin.nuget\packages\livesharp\1.0.57\build\LiveSharp.targets(18,5): warning : LiveSharp processing failed 1> 1> 4 Warning(s) 1> 0 Error(s) 1> 1>Time Elapsed 00:00:22.95 ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
LiveSharp.BuildAgent.exe console window:
Message: Received message: rebuild C:\Users\Admin\Documents\Visual Studio 2017\Projects\App1\App1\App1.Android\obj\Debug\81\livesharp.build.order Error: LiveSharp.Runtime.dll wasn't found in obj\Debug\81\
Build -> Build succeeded
Debug -> OK
Clean, Debug -> OK
Rebuild, Debug -> OK
Delete bin + obj, Debug -> ERROR same as above
@ionoy I would also argue including the LiveSharp.Runtime.dll in the NuGet package would be a good approach while a proper solution has not been found.
This also causes issues for us using VSCode, where all IntelliSense and code completion will stop working after first build, as Omnisharp crashes due to the missing dll. It can be fixed by dotnet clean
and reloading the window, but this is not ideal, when using VSCode as a main IDE.
EDIt: Given this an old issue, is there any progress on a better approach?
@niem94 LiveSharp.Runtime.dll is already included in the NuGet package. I'll need to test this scenario to see why the build task cannot find it.
By the way, is actually happening during the build or just for IntelliSense stuff?
@ionoy the error is reported by OmniSharp after loading a project that has been built with LiveSharp included. So to answer your question — no it is not happening during the build, but it happens when OmniSharp (VSCode) loads/analyzes the project.
OmniSharp can't seems to be able to load a projet having LiveSharp as a dependency, I get the error below.
Project builds fine, Projects debug fine but we loose all VSCode intellisense since the project does not load properly
Also, LiveSharp.Runtime.dll does exist in the bin folder.
Like @niem94 said, I have to dotnet clean the project and then reload OmniSharp before I build the project.
Please try this build and see if it fixes the issue. LiveSharp.1.5.78.zip
Build 1.5.78 seems to fix the issue!! Thanks @ionoy that was quick!
VSIX: 1.0.38, NuGet: 1.0.51 Uninstall LiveSharp NuGets and VSIX, reinstall, then on rebuild and subsequent build this error occurs:
LiveSharp exception: System.MissingMethodException: Method not found: 'Mono.Collections.Generic.Collection
1<Mono.Cecil.MethodDefinition> Mono.Cecil.Cil.AsyncMethodBodyDebugInformation.get_ResumeMethods()'. at Mono.Cecil.Pdb.NativePdbReader.Read(MethodDefinition method) at Mono.Cecil.Cil.CodeReader.ReadMethodBody() at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method) at Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader) at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func
3 read) at Mono.Cecil.MethodDefinition.get_Body() at LiveSharp.Build.LiveSharpTask.InjectStartCall(MethodDefinition constructor, LiveSharpContext context) at LiveSharp.Build.LiveSharpTask.ProcessEverything() Bridg.Android C:\Users\Admin\Source\Repos\Apps\Bridg\packages\LiveSharp.1.0.51\build\LiveSharp.targets 16Close and reopen VS, then build -> error gone
Sometimes after NuGet update this error occurs on build:
"LiveSharp.Runtime.dll wasn't found in obj\Debug\"
This error also occurs when switching branches from a branch that does not have LiveSharp NuGet packages to one that does. Also here: close and reopen VS, then build again -> error gone