App + .NET Standard with Click Once

Unable to initialize the application (Could not load file or assembly ‘System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ or one of its dependencies. The System cannot find the file specified.

Unable to install or run the application.  The application requires that the assembly System.Drawing.Primitives Version 4.02.0 be installed in the Global Assembly Cache (GAC) first.  Please contact your system administrator

The following guide will resolve the current Click Once deployment bug in Visual Studio Community to Visual Studio Enterprise (Versions 15.6.7 and lower).

Note this fix is specifically for Application Executables in .NET Framework (4.6.1).

TECHNOLOGY

.NET Standard

Framework

CATEGORIES

Click Once Deployment

CODE

C# | C Sharp

Replicating the Issue:

Replication was tested on 7/20/2018

Create a new solution with an Executable App (Win Forms  App or WPF App).
  • File > New Project > Visual C# > Windows Classic Desktop > WPF App (.NET Framework)
  • Framework: .NET Framework 4.6.1
Add a new .NET Standard Project to your Executable App Solution
  • Solution > New > New Project > Visual C# > .NET Standard > Class Library (.NET Standard)
Add .NET Standard Reference to your Executable Application
  • WpfApp1 > Reference > Add Reference… > Projects > ClassLibrary1
Build and Publish your Executable Application
  • WpfApp1 > Publish > Finish
  • Run Setup.exe on deployed machine returns the GAC error

Resolving the Issue:

Microsoft is already aware of this issue and has a scheduled fix to be implemented in Visual Studio Versions 15.7 +

Modifying Executable App Publish Settings
  • WpfApp1 > Right Click > Properties > Publish > Application Files
Including .NET Standard Assemblies with Click Once
  • Application Files > Publish Status > Include > *.DLL
  • WpfApp1 > Publish > Finish
  • Run Setup.exe on deployed machine

Resources:

https://stackoverflow.com/questions/45843533/clickonce-deployment-does-not-install-as-expected

https://github.com/dotnet/standard/issues/529