Strange error while trying to use desktop bridge for wpf - desktop-bridge

I am trying to use Visual studio project template for desktop bridge to add to wpf app and it will not build successfully and shows this strange warning that i have attached.
warning when building desktop bridge project template
i had followed this post on official documentation :
https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-packaging-dot-net
and before that i had used this blog post to add winmd and runtime to my project:
https://blogs.windows.com/buildingapps/2017/01/25/calling-windows-10-apis-desktop-application/
and here is the code form Package.appxmanifest file:
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10" IgnorableNamespaces="uap mp rescap iot">
<Identity Name="09b95fbd-84cc-426f-9fd2-2c1d3d304fab" Publisher="CN=SO-PC-005" Version="1.0.0.0" />
<Properties>
<DisplayName>WapProjTemplate</DisplayName>
<PublisherDisplayName>SO-PC-005</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="$targetentrypoint$">
<uap:VisualElements DisplayName="WapProjTemplate" Description="WapProjTemplate" BackgroundColor="transparent" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<iot:Capability Name="systemManagement" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
I also would like to mention that i am trying to use windows.graphics.display for brightness override in a wpf app and it requires systemManagement capapbility. And also that my project builds successfully without packaging project but when I add packaging project to my wpf solution it will not build.

Related

NuGet: Package was restored using .NET Framework instead of net5.0

I am new to both .NET core and NuGet releasing.
I built a .NET Core 5.0 class library.
I built a .NET Core 5.0 console app to test this class library
If the test console app directly reference the DLL built from this class library, everything works fine.
If I build a NuGet package using the class library and release it, then download that package to the test console app, I get this warning:
"Package SkyBridge.ClientAPI.NetCore 1.0.0.3 was restored using
.NETFramework,Version=v4.6.1,
.NETFramework,Version=v4.6.2,
.NETFramework,Version=v4.7,
.NETFramework,Version=v4.7.1,
.NETFramework,Version=v4.7.2,
.NETFramework,Version=v4.8
instead of the project target framework net5.0.
This package may not be fully compatible with your project."
This is the nuspec file:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>SkyBridge.ClientAPI.NetCore</id>
<version>1.0.0.3</version>
<title>SkyBridge.ClientAPI (.NET Core)</title>
<authors>Front Edge Software, Frank Lieu</authors>
<owners>Front Edge Software, Frank Lieu</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="file">SkyBridge_Client_API_Software_License_Agreement.txt</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<description>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</description>
<summary>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</summary>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright ©2021 Front Edge Software</copyright>
<tags>Front Edge SkyBridge Client API Remoting</tags>
<dependencies>
<dependency id="Crc32.NET" version="1.2.0" />
<dependency id="BouncyCastle.NetCore" version="1.8.10" />
<dependency id="BouncyCastle.NetCoreSdk" version="1.9.3.1" />
<dependency id="System.Configuration.ConfigurationManager" version="6.0.0" />
</dependencies>
</metadata>
<files>
<file src="SkyBridge_Client_API_Software_License_Agreement.txt" target="" />
</files>
</package>
What is the problem?
The following nuspec solved the problem - I specified the .NET dependency:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>SkyBridgeAPI.NetCore</id>
<version>1.0.0.6</version>
<title>SkyBridgeAPI (.NET Core)</title>
<authors>Front Edge Software, Frank Lieu</authors>
<owners>Front Edge Software, Frank Lieu</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="file">SkyBridgeAPI_Software_License_Agreement.txt</license>
<licenseUrl>https://aka.ms/deprecateLicenseUrl</licenseUrl>
<description>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</description>
<summary>A class library used to act as a SkyBridge client and communicate with another SkyBridge client.</summary>
<releaseNotes>Initial release.</releaseNotes>
<copyright>Copyright ©2021 Front Edge Software</copyright>
<tags>Front Edge SkyBridge API Remoting</tags>
<dependencies>
<group targetFramework="net5.0">
<dependency id="Crc32.NET" version="1.2.0" />
<dependency id="BouncyCastle.NetCore" version="1.8.10" />
<dependency id="BouncyCastle.NetCoreSdk" version="1.9.3.1" />
<dependency id="System.Configuration.ConfigurationManager" version="6.0.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="SkyBridgeAPI_Software_License_Agreement.txt" target="" />
<file src="lib\net5.0\FrontEdge.SkyBridgeAPI.dll" target="lib\net5.0" />
</files>
</package>

VFP Reports cutoff with display scaling > 100%

When printing/previewing reports in VFP and display scaling is > 100%, the report preview is enlarged, but the "paper size" is not, and this is causing the report to be cut off. Note: the gray area around the image is the preview background indicating the size of the "paper".
I have tried a custom manifest setting the dpiAware to true.
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>
</windowsSettings>
</application>
I tried using the API to set it.
DECLARE INTEGER SetProcessDPIAware in WIN32API
=SetProcessDPIAware()
The only thing that seems to work is overriding the high DPI scaling in the shortcut. The problem with that is the application is used on laptops and the screen is fairly small, so the forms are too small and the customer doesn't like that solution.
Somewhere, I read that FoxyPreviewer handed that issue, but it isn't (not for me). I can't remember where I saw it.
I'm running on Windows 10 Build 17134. VFP9 SP2.
Save the following manifest as exeName+".exe.manifest"
on your project folder.
( VFP9 Sp2 will include it upon exe generation. )
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" type="win32" name="Microsoft.VisualFoxPro" processorArchitecture="x86" />
<description>Visual FoxPro 9 application</description>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" />
</requestedPrivileges>
</security>
</trustInfo>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True</dpiAware>
</windowsSettings>
</application>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" language="*" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" />
</dependentAssembly>
</dependency>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
</assembly>

Protocol activation of WPF application not working when installed using appinstaller

I have a WPF desktop application that I have packaged into an MSIX package. In the package manifest I have defined a windows.protocol extension to launch the main executable when a specific protocol is used. This protocol activation works fine when I install using the MSIX package directly.
The application should be auto-updating, so I created a .appinstaller file that references the MSIX. That also works well, but when the application is installed using the .appinstaller file, the protocol activation does not work. In fact Windows prompt for an application when the custom protocol is used. I have not changed the MSIX package in any way, just referenced it. The MSIX package is signed using a valid bought signing certificate.
The protocol in question provides deep links into the application that users can share using email.
For the moment I have to choose to either have protocol activation (install the MSIX directly) or auto-updating (install using the .appinstaller file), but I can't get both to work.
appmanifest.xml
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap uap3 rescap">
<Identity
Name="MyApp"
Publisher="CN=CompanyName, O=CompanyName, L=City, S=Province, C=BE"
Version="1.0.0.0"
ProcessorArchitecture="x64"/>
<Properties>
<DisplayName>MyApp</DisplayName>
<PublisherDisplayName>CompanyName</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="MSIXCore.Desktop" MinVersion="6.1.7601.0" MaxVersionTested="10.0.10240.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.18362.0" />
</Dependencies>
<Resources>
<Resource Language="en-us"/>
</Resources>
<Applications>
<Application Id="App"
Executable="MyApp\MyApp.exe"
EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="MyApp"
Description="MyApp"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
<Extensions>
<uap3:Extension Category="windows.protocol">
<uap3:Protocol Name="myprotocol" Parameters="-s "%1"">
<uap:DisplayName>MyProtocol Scheme</uap:DisplayName>
</uap3:Protocol>
</uap3:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
<Capability Name="privateNetworkClientServer"/>
<uap:Capability Name="userAccountInformation"/>
</Capabilities>
</Package>
myapp.appinstaller
<?xml version="1.0" encoding="utf-8"?>
<AppInstaller Uri="\\someserver\someshare\myapp.appinstaller" Version="1.0.0.0" xmlns="http://schemas.microsoft.com/appx/appinstaller/2018">
<MainPackage Name="MyApp" Version="1.0.0.0" Publisher="CN=CompanyName, O=CompanyName, L=City, S=Province, C=BE" ProcessorArchitecture="x64" Uri="\\someserver\someshare\myapp.msix" />
<UpdateSettings>
<OnLaunch HoursBetweenUpdateChecks="0" ShowPrompt="true" UpdateBlocksActivation="true"/>
<AutomaticBackgroundTask/>
</UpdateSettings>
</AppInstaller>

How to include the multiple .NET Standard versions in the NuGet package

I have created the two projects with respect to support .NET Standard version 1.2 & 1.4 and refer the project.json as per target version. Then create the NuGet package with nuspec below.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>package id</id>
<version>15.1120.0.1</version>
<authors></authors>
<owners></owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<licenseUrl> </licenseUrl>
<projectUrl></projectUrl>
<iconUrl> </iconUrl>
<description> </description>
<copyright></copyright>
<tags> </tags>
<dependencies>
<group targetFramework=".NETStandard1.2">
<dependency id="Microsoft.NETCore.Portable.Compatibility"
version="1.0.1" />
<dependency id="NETStandard.Library" version="1.6.0" />
</group>
<group targetFramework=".NETStandard1.4">
<dependency id="Microsoft.NETCore.Portable.Compatibility" version="1.0.1" />
<dependency id="NETStandard.Library" version="1.6.0" />
</group>
</dependencies>
</metadata>
</package>
It creates the package properly. Now I want to refer this package in the .NET core 1.0 version application with .NET framework 4.6.1. As pre-the .NET Standard Support It should refer the .NET Standard 1.4 version. But it refers .NET Standard 1.2 reference. What I was missing in the package creation. Also,can we please let me know whether we can include multiple target in .NET Standard or not?

.NET Web Deployment Tool with log4Net: Not overwriting logs

I'm using the Web Deployment Tool to build and release an MVC site from VS 2010 to a server running IIS. I also have log4net logging to a subdirectory off of the root of the web application I'm deploying to. I already figured out how to keep write permissions intact when deploying with this tool on that directory, but now I'm running into the problem that I'd rather not lose the logs when deploying, and also, the deploy is failing because the log file that log4net is using is "used by another process" (presumably w3wp) and won't let the deploy continue.
So, I'd like to preserve the log files and not delete or overwrite them, for auditing purposes. Is there a way to do that within the confines of the Web Deployment Tool?
EDIT: Here's the applicable bits of the log4net configuration, in Web.Config.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net" />
</configSections>
<log4net>
<appender name="RollingLog" type="log4net.Appender.RollingFileAppender">
<param name="File" value="Logs\Log.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Composite" />
<maxSizeRollBackups value="20" />
<maximumFileSize value="10MB" />
<datePattern value="yyyyMMdd" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="{%level}%date{MM/dd HH:mm:ss} - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingLog" />
</root>
</log4net>
</configuration>
Found it by hunting around: there is a "skip" parameter you can tack on to the command when you call the pre-packaged deploy script. You HAVE to use a regular old CMD prompt for this; Powershell's crazy escaping of quotes makes it near-impossible to get right, so I gave up. Anyway, here's the end result I came up with:
.\MyProject.deploy.cmd /Y /M:MyServerName "-skip:skipAction=Delete,objectName=filePath,absolutePath=Logs"
"MyProject.deploy.cmd" being the name of the prepackaged deploy command, "MyServerName" being the name of the server I was deploying to, and "Logs" being the name of the folder I wanted to skip. This command seems to leave alone that Logs directory and deploy anything else that matters.
Source where I started to hone in on things: http://blogs.iis.net/msdeploy/archive/2009/04/23/what-has-changed-about-skip-replace-rules-in-rc.aspx
Set locking model of your appender to minimal lock and everything will be fine:
<appender name="RollingLog" type="log4net.Appender.RollingFileAppender">
...
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
...
</appender>
log4net.Appender.FileAppender (see remarks)

Resources