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

[Problem/Bug]: NuGet package Microsoft.Web.WebView2 build files do not work in some MsBuild scenarios #4923

Open
joergrosenkranz opened this issue Nov 13, 2024 · 6 comments
Assignees
Labels
bug Something isn't working regression Something used to work but doesn't anymore

Comments

@joergrosenkranz
Copy link

What happened?

Building a CSPROJ with MSBuild does not work when the targets restore and Build are called in the same MSBuild run.

The error was introduced with the new non-standard NuGet structure.

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

1.0.2849.39

Framework

Winforms

Operating System

Windows 10

OS Version

No response

Repro steps

Create a sample project:

dotnet new classlib -f net8.0 -o WebView2Test
cd .\WebView2Test\
dotnet add package Microsoft.Web.WebView2

Add a Test.cs file:

namespace WebView2Test;

using Microsoft.Web.WebView2.Core;

public class Test
{
    public static async Task Initialize()
    {
        await CoreWebView2Environment.CreateAsync();
    }
}

Build using this command:

msbuild /T:"restore;Build" .\WebView2Test.csproj

Result (sorry, machine has German culture):

error CS0234: Der Typ- oder Namespacename "Web" ist im Namespace "Microsoft" nicht vorhanden. (Möglicherweise fehlt ein Assemblyverweis.)

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Regression in newer SDK

Last working version (if regression)

1.0.2592.51

@joergrosenkranz joergrosenkranz added the bug Something isn't working label Nov 13, 2024
@github-actions github-actions bot added the regression Something used to work but doesn't anymore label Nov 13, 2024
@oggy22
Copy link
Member

oggy22 commented Nov 13, 2024

Thank you for reporting. Can you please try with the latest prerelease https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.2895-prerelease. The issue might have been fixed.

@joergrosenkranz
Copy link
Author

No, the bug is not fixed with the preview version.

@oggy22
Copy link
Member

oggy22 commented Nov 15, 2024

Ok, thanks for trying. Can you please provide a min repro so we can try to repro your problem? Ideally it should be a min repro which means it all unnecessary pieces would be removed.

@joergrosenkranz
Copy link
Author

The minimal repro is already in the repro steps of the bug report.

@ambikakunnath
Copy link
Member

I'm unable to repro the issue with the repro steps mentioned. Can you please check if there is anything else needed for the repro? Can you confirm if the project file has the WebView2 package dependency included:
image

@joergrosenkranz
Copy link
Author

If the PackageReference is not there, you've missed this command in the repro steps:

dotnet add package Microsoft.Web.WebView2

Here you can see the complete project:
WebView2Test.zip

Repro is simple:

  • Unzip the folder
  • Open Developer Command Prompt for VS 2022
  • Run this command:
    msbuild /T:"restore;Build" .\WebView2Test.csproj
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something used to work but doesn't anymore
Projects
None yet
Development

No branches or pull requests

3 participants