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

Self contained publish fails when using winappsdk 1.1 and microsoft.identity.client #2492

Open
jmiddour opened this issue May 10, 2022 · 15 comments
Assignees
Labels
area-DeveloperTools Issues related to authoring (source and IDL), debugging, HotReload, LiveVisualTree, VS integration bug Something isn't working

Comments

@jmiddour
Copy link

Describe the bug

When trying to publish a self contained app using windows app sdk 1.1 preview 2 and Microsoft Identity Client 4.43.2 I'm getting an error:
image

I think the issue is that the publish isn't picking up that the file is already requested. I've tried suppressing duplicate file errors and setting an itemgroup remove for it, but nothing has worked so far.

ideas?

Steps to reproduce the bug

Create a new winui3 desktop app.
Add a winui3 class library that the app references
add the microsoft identity client to the class library
attempt to publish the app

Expected behavior

No response

Screenshots

No response

NuGet package version

1.1.0-preview1

Packaging type

Packaged (MSIX)

Windows version

Windows 10 version 2004 (19041, May 2020 Update)

IDE

Visual Studio 2022-preview

Additional context

No response

@mikebattista
Copy link

This may be a duplicate of #1856. Could you take a look at that and see if it's the same issue?

@jmiddour
Copy link
Author

jmiddour commented May 11, 2022

@mikebattista based on the thread, it is similar but doesn't appear to be the same.
I do not have the private assets or runtime includes specified. I'm including the package reference section of the library project:
image
If there is another possible work around, I'm willing to try it. As far as I can tell the Identity client is the only thing actively using the webview2 dll.

@jmiddour
Copy link
Author

jmiddour commented May 11, 2022

I possibly found a work around based on what was mentioned in the other thread(s) ...
If I add

<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.1185.39">
      <ExcludeAssets>compile;runtime</ExcludeAssets>
    </PackageReference>

to my application project, I get past the error I had above. However, it now fails because it cannot find the dll of my library project because it is looking in a runtime folder that the compile didn't output to.
it is looking for the dll here:
image
instead of where it was actually output, here:
image

@mikebattista
Copy link

Also when you say self-contained "publish", are you doing dotnet publish? Or something else?

@jmiddour
Copy link
Author

The errors above were when I did a right click, publish on the application project in visual studio. That ultimately isn't the typical app deployment method, so it may end up being behavior not supported in the long run.

When I try generating the app packages option, VS2022 17.3-preview 1 crashed. I made sure everything I could find was updated appropriately and it still crashed every time.

I did finally get a msix built from the command line, so I have something working now. I'll be refining what i've done so far, so I may have more/better info over the next couple weeks.

@mikebattista
Copy link

Thanks. dotnet publish which is also what the Publish... dialog uses is not supported yet with WinAppSDK. If this is an MSIX project, you want to use the Package and Publish -> Create App Packages... dialog instead from the same project context menu. Could you try that? If the app is configured to be self-contained, that content should be carried within the MSIX package.

@btueffers btueffers added bug Something isn't working area-DeveloperTools Issues related to authoring (source and IDL), debugging, HotReload, LiveVisualTree, VS integration labels May 12, 2022
@jmiddour
Copy link
Author

When I try create app packages, visual studio crashes entirely -- no dialog/wizard shows; just a crash report to MS followed by a vs restart.

@mikebattista
Copy link

I have hit this too in the past and debugged with VS. There's a hidden .suo file under <SOLUTION>/.vs/<APPNAME>/v17/ and also potentially a .csproj.user right next to the .csproj. Could you back those up somewhere, then delete those files and try again?

@jmiddour
Copy link
Author

I deleted all .vs/.user/bin/obj directories entirely. Now when I try it, it still crashes but Visual Studio will let me throw it to debug.

Here is the exception details from the debugger:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Microsoft.VisualStudio.AppxPackage
  StackTrace:
   at Microsoft.VisualStudio.AppxPackage.PublishAppXViewModelBase.<>c__DisplayClass23_0.<<GetUserBoolSetting>b__0>d.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
   at Microsoft.VisualStudio.AppxPackage.PublishAppXViewModelBase.GetUserBoolSetting(String name, Boolean defaultValue)
   at Microsoft.VisualStudio.AppxPackage.PickProductViewModel.LoadUserSettingsOrDefault()
   at Microsoft.VisualStudio.AppxPackage.PickProductViewModel..ctor(PublishAppXResult result)
   at Microsoft.VisualStudio.AppxPackage.PackageDialog.PublishAppXNavigationFactory.CreateNavigationTree(IPageNavigator nav, INavigationPageHost host)
   at Microsoft.VisualStudio.WizardFrameworkWpf.WizardBase.InitializeInternal(INavigationTreeFactory navigationTreeFactory)
   at Microsoft.VisualStudio.AppxPackage.Commands.Packaging.<PackageAppxMenuItemExec>d__27.MoveNext()
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

  This exception was originally thrown at this call stack:
    Microsoft.VisualStudio.AppxPackage.PublishAppXViewModelBase.GetUserBoolSetting.AnonymousMethod__0()
    System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
    System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
    Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
    Microsoft.VisualStudio.AppxPackage.PublishAppXViewModelBase.GetUserBoolSetting(string, bool)
    Microsoft.VisualStudio.AppxPackage.PickProductViewModel.LoadUserSettingsOrDefault()
    Microsoft.VisualStudio.AppxPackage.PickProductViewModel.PickProductViewModel(Microsoft.VisualStudio.AppxPackage.PublishAppXResult)
    Microsoft.VisualStudio.AppxPackage.PackageDialog.PublishAppXNavigationFactory.CreateNavigationTree(Microsoft.VisualStudio.WizardFrameworkWpf.IPageNavigator, Microsoft.VisualStudio.WizardFrameworkWpf.INavigationPageHost)
    Microsoft.VisualStudio.WizardFrameworkWpf.WizardBase.InitializeInternal(Microsoft.VisualStudio.WizardFrameworkWpf.INavigationTreeFactory)
    Microsoft.VisualStudio.AppxPackage.Commands.Packaging.PackageAppxMenuItemExec(object, System.EventArgs)
    ...
    [Call Stack Truncated]

I'm happy to help if you want to continue to trace this down, but please keep in mind -- I'm running preview VS with preview WinAppSDK and could very well have messed something up in my install by adding or removing extensions from the early winappsdk builds. In other words, I wouldn't be shocked if this particular issue was not reproducible.

I was much more concerned about the other issues that we've already addressed as at least relatively known -- even if it wasn't clear to me that they were related initially.

@mikebattista
Copy link

Thanks. Yes that is exactly the known issue I have hit and is specific to the 1.1 preview release. VS is investigating. It's not a 100% repro and the workaround for me was to remove both the .suo and csproj.user files I mentioned, but I've heard that doesn't always work. If you hit this and need to produce an MSIX, you can do so from the command line with tools like makeappx.

Regarding the original APPX1101 issue, we are investigating that.

@mikebattista
Copy link

I'm following up with the WebView2 team on this issue. It's definitely WebView2 specific and not the same as the other issue I linked, given it's included in WinAppSDK but also pulled in as a transitive dependency from the identity client library.

@keithbo1961
Copy link

Did this issue ever get resolved? I am using WinAppSDK 1.1.5 and still getting the msix duplication failure with WebView2.

@NeilQ
Copy link

NeilQ commented Dec 2, 2022

Same issue about msix webview2 when using Microsoft.Data.SqlClient >=5.00, and works with Microsoft.Data.SqlClient 4.1.1

@rossirpaulo
Copy link

No updates?

@kmgallahan
Copy link

@mikebattista @bpulliam This is still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-DeveloperTools Issues related to authoring (source and IDL), debugging, HotReload, LiveVisualTree, VS integration bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants