Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio Build Error #137

Open
DanielHabenicht opened this issue Jan 11, 2024 · 7 comments
Open

Visual Studio Build Error #137

DanielHabenicht opened this issue Jan 11, 2024 · 7 comments
Labels
bug Something isn't working external The issue is caused by a third-party help wanted Community help is most appreciated

Comments

@DanielHabenicht
Copy link

DanielHabenicht commented Jan 11, 2024

Just hope that maybe somebody else came across the same error:

error MSB4062: The "Bootsharp.Publish.BootsharpEmit" task could not be loaded from the assembly C:\Users\dnhb\.nuget\packages\bootsharp\0.1.3\build\..\tasks\Bootsharp.Publish.dll. Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
4>Done building target "BootsharpEmit" in project "Project.csproj" -- FAILED

dotnet build is running just fine. Only VS gives problems.

@elringus elringus added bug Something isn't working help wanted Community help is most appreciated external The issue is caused by a third-party labels Jan 11, 2024
@elringus
Copy link
Owner

Not using Visual Studio myself (not reproducing in Rider). If anyone have an idea on possible workarounds on our end, please let us know here.

@elringus elringus added this to the First stable release milestone Jan 11, 2024
@mingyaulee
Copy link

Visual Studio requires the build tasks to target net472

@elringus
Copy link
Owner

elringus commented Feb 2, 2024

Visual Studio requires the build tasks to target net472

That's unfortunate. Are there any tracking issues for VS to support modern .NET?

@mingyaulee
Copy link

I guess to quote from this page,

  • Full MSBuild: This version of MSBuild usually lives inside Visual Studio. Runs on .NET Framework. Visual Studio uses this when you execute Build on your solution or project. This version is also available from a command-line environment, such as the Visual Studio Developer Command Prompt, or PowerShell.
  • .NET MSBuild: This version of MSBuild is bundled in the .NET Core Command Line. It runs on .NET Core. Visual Studio doesn't directly invoke this version of MSBuild. It only supports projects that build using Microsoft.NET.Sdk.

It doesn't look like it's going to change anytime soon.

@elringus
Copy link
Owner

elringus commented Feb 3, 2024

I've explored downgrading everything to .NET Standard 2.0 and while there are shims for most stuff, I wasn't able to find one for https://learn.microsoft.com/en-us/dotnet/api/system.reflection.nullabilityinfo, which is required for detecting nullable/optional parameters. Also we are using reflection extensively on build, so there could be other issues due to TF mismatch, even if everything would compile.

Overall, I think it'd make more sense to figure a workaround for VS users instead of downgrading target framework. For example, maybe we can somehow detect VS or .NET version in the build script and invoke dotnet publish via <Exec .... If someone happen to make this work (or have other ideas), please share/send a PR.

@DanielHabenicht
Copy link
Author

Thats ok, we are also just working around it by using the dotnet commands.

The main logic of the app is in a different project anyhow, so VS developers can just disable the Bootsharp based project and switch to commandline if they need to.

The goal of opening this issue (from my mind) was just to highlight the problem, and maybe find a workaround. I also think that working on backwards compatibility is not worth it if its that big of a task.

@mingyaulee
Copy link

One solution I have adopted for my project earlier is to target both net8.0 and also net472, and package the binaries of the libraries that don't exist in the net472 runtime into the nuget package. It's not complicated but it just takes a bit of time to test and make sure it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working external The issue is caused by a third-party help wanted Community help is most appreciated
Projects
None yet
Development

No branches or pull requests

3 participants