Issue Deploying Install/Updates On GitHub with ClickOnce - c#

I've been trying to figure out the best way to deploy a WPF application with ClickOnce. I'd download the setup file from the GitHub URL, and cross my fingers, and run into this every time:
PLATFORM VERSION INFO
Windows : 10.0.15063.0 (Win32NT)
Common Language Runtime : 4.0.30319.42000
System.Deployment.dll : 4.7.2046.0 built by: NET47REL1
clr.dll : 4.7.3130.0 built by: NET472REL1LAST_B
dfdll.dll : 4.7.2046.0 built by: NET47REL1
dfshim.dll : 10.0.15063.0 (WinBuild.160101.0800)
SOURCES
Deployment url : https://github.com/SuperScrub837/tree/master/SuperScrub837/SuperScrub837/publish/SuperScrub837.application
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of https://github.com/SuperScrub837/tree/master/SuperScrub837/SuperScrub837/publish/SuperScrub837.application resulted in exception. Following failure messages were detected:
+ Exception reading manifest from https://github.com/SuperScrub837/blob/master/SuperScrub837/SuperScrub837/publish/SuperScrub837.application: the manifest may not be valid or the file could not be opened.
+ DTD is prohibited in this XML document.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
* [8/14/2018 8:21:48 PM] : Activation of https://github.com/SuperScrub837/tree/master/SuperScrub837/SuperScrub837/publish/SuperScrub837.application has started.
ERROR DETAILS
Following errors were detected during this operation.
* [8/14/2018 8:21:50 PM] System.Deployment.Application.InvalidDeploymentException (ManifestParse)
- Exception reading manifest from https://github.com/SuperScrub837/blob/master/SuperScrub837/SuperScrub837/publish/SuperScrub837.application: the manifest may not be valid or the file could not be opened.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestDirectBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options, ServerInformation& serverInformation)
at System.Deployment.Application.DownloadManager.DownloadDeploymentManifestBypass(SubscriptionStore subStore, Uri& sourceUri, TempFile& tempFile, SubscriptionState& subState, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl, Uri& deploymentUri)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)
--- Inner Exception ---
System.Xml.XmlException
- DTD is prohibited in this XML document.
- Source: System.Xml
- Stack trace:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.ParseDoctypeDecl()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Deployment.Application.ManifestValidatingReader.XmlFilteredReader.Read()
at System.Xml.XsdValidatingReader.Read()
at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
COMPONENT STORE TRANSACTION DETAILS
No transaction information is available.
I've been trying to follow some blogs that I've found, and have created the following in .gitignore:
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
#Allow publish directory
!publish/
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Typescript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
Here is the code in my .gitattributes file:
*.manifest binary
*.application binary
*.deploy binary
This is turning out to be a bit more of a pain point for me than I probably should be making it. I want the user to be able to install from the GitHub link, and update the application.
Thoughts?

So, the purpose of publishing my ClickOnce executables on GitHub was to allow updates to be downloaded from this repository as my software was updated. As many people on this website are aware, GitHub discourages downloading raw files since they usually intend themselves to be a repository system for the code itself - they don't want to have long download times, etc.
Keep in mind, at least at the moment this app I've been building is lightweight, so since I don't have an alternative at the moment with my available resources, I've decided to keep these updating executables on the repo itself. If one wants to do that, here's a tip, which you may have seen before - try using the following URL:
https://github.com/SuperScrub837/raw/master/SuperScrub837/SuperScrub837/publish/
Instead of:
https://github.com/SuperScrub837/tree/master/SuperScrub837/SuperScrub837/publish/
in your ClickOnce preferences for the project.
When I used the raw version of the link, the deployed application on another application updated successfully without any errors. Hope this helps and isn't too extra - also, this article may belong on ServerFault or something, so my apologies if that's the case since I posed this question here.

The error exists as you have not used raw GitHub for file hosting. Raw GitHub is essentially like a free FTP server which you can use for free hosting your .NET applications.
Follow the following steps:
(I have also created an illustrative video for the same here: https://youtu.be/iMEGtrjMXPU)
If your project isn't on GitHub, create a repository and push your code there. It has to be public.
On your computer, create a folder called 'published' at the root of your repository. Make sure this folder is not ignored in the .gitignore
Create a file called .gitattributes in this /published folder. Add the following contents
*.manifest binary
*.application binary
*.deploy binary
* -text
Now commit and push to the Github repository. Navigate to this file in the repository click on the RAW button. Copy the URL address till '/publish/'. It will look like this
https://raw.githubusercontent.com/{your-account-name}/{your-repo-name}/{branch}/published/
In the ClickOnce installer enter the following paths
Publish Path:
{repo-path}/pubhished
Install Path:
https://raw.githubusercontent.com/{your-account-name}/{your-repo-name}/{branch}/published/
This is the server address from where the setup will install your application from.
Update Path:
https://raw.githubusercontent.com/{your-account-name}/{your-repo-name}/{branch}/published/
This is the server address from where the setup will check for updates.
NOTE: Use this link to navigate through the clickonce installer:
https://learn.microsoft.com/en-us/visualstudio/deployment/quickstart-deploy-using-clickonce-folder?view=vs-2022.
Make sure the check the 'Create Desktop Shortcut' option before publishing. Now commit and push your code.
Now in the /published folder click on the setup to install the application. This will connect the GitHub servers to download and install the required files on your computer in the directory C:\Users\vib28\AppData\Local\Apps\2.0.
To publish an update for the application follow these steps
Make the changes to your c# applicaiton.
Publish the application again (to the same folder /published). The revision number should increase, and there should be a new folder added to the location /published/Application Files
Commit and push your code to GitHub. Now the raw files have been updated. So whenever the client runs his application, it will automatically prompt for downloading the update.

Related

How to ignore all sensitive or cache files for dotnet core development with Rider?

No matter which gitignore I use, whever its from gitignore.io, official github, .gitignores copied from popular public repositories, it wont ignore useless folders and files such as obj, package caches, .idea folder related files, etc.
Files I want to ignore, but are still showing up as changes:
<project-path>\obj\project.nuget.cache
<project-path>\obj\Debug\netcoreapp3.1\ProjectName.AssemblyInfo.cs
<project-path>\obj\Debug\netcoreapp3.1\ProjectName.csproj.nuget.g.props
Current gitignore:
### DotnetCore ###
# .NET Core build folders
/bin
/obj
# Common node modules locations
/node_modules
/wwwroot/node_modules
### Rider ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
.idea/
*.sln.iml
this happens for me sometimes,
I do this to fix
git rm -r --cached .
git add .
git commit -m "fix gitignore file"

Android build error "failed to create JavaTypeInfo for class" :Xamarin

Following this tutorial https://github.com/Vidyo/vidyo.io-connector-xamarin I downloaded the app without making any changes.
When I build the app, I get the following error:
Severity Code Description Project File Line Suppression State
Error Failed to create JavaTypeInfo for class: Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/ITouchExplorationStateChangeListenerImplementor due to MAX_PATH: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\Users\User\Desktop\vidyo.io-connector-xamarin-master\vidyo.io-connector-xamarin-master\VidyoConnector.Android\obj\Debug\90\android\src\mono\android\support\v4\view\accessibility\AccessibilityManagerCompat_TouchExplorationStateChangeListenerImplementor.java'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalDelete(String path, Boolean checkHost)
at System.IO.File.Delete(String path)
at Xamarin.Android.Tools.Files.CopyIfStreamChanged(Stream stream, String destination)
at Xamarin.Android.Tasks.Generator.CreateJavaSources(TaskLoggingHelper log, IEnumerable`1 javaTypes, String outputPath, String applicationJavaClass, String androidSdkPlatform, Boolean useSharedRuntime, Boolean generateOnCreateOverrides, Boolean hasExportReference) VidyoConnector.Android
What is the possible fix for this?
That seems a problem with long path in windows. Put the project folder on the root, say C://yourproject. Then, clean your solution and build.
#LawrenceWlt is correct but I would like to add some more information.
Is is due to Maximum Path Length Limitation
In the Windows API (with some exceptions discussed in the following
paragraphs), the maximum length for a path is MAX_PATH, which is
defined as 260 characters.
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation
If you are on Windows 10, Version 1607 or later you can Enable Long Paths:
The registry key Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem\LongPathsEnabled (Type: REG_DWORD) must exist and be set to 1.
The application manifest must also include the longPathAware element.
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings xmlns:ws2="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
<ws2:longPathAware>true</ws2:longPathAware>
</windowsSettings>
</application>
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation#enable-long-paths-in-windows-10-version-1607-and-later
I got a similar error from Experimental Mobile Blazor Bindings:
https://github.com/xamarin/MobileBlazorBindings
Failed to generate Java type for class:
Android.Support.V4.View.Accessibility.AccessibilityManagerCompat/IAccessibilityStateChangeListenerImplementor
due to MAX_PATH: System.IO.DirectoryNotFoundException: Could not find
a part of the path
'C:\Users\User\Desktop\MobileBlazorBindings-master\samples\MobileBlazorBindingsXaminals\MobileBlazorBindingsXaminals.Android\obj\Debug\90\android\src\mono\android\support\v4\view\accessibility\AccessibilityManagerCompat_AccessibilityStateChangeListenerImplementor.java'.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.InternalDelete(String path, Boolean checkHost) at
System.IO.File.Delete(String path) at
Xamarin.Android.Tools.Files.CopyIfStreamChanged(Stream stream, String
destination) at
Xamarin.Android.Tasks.GenerateJavaStubs.CreateJavaSources(IEnumerable`1
javaTypes, TypeDefinitionCache
cache) MobileBlazorBindingsXaminals.Android
Adding this to the Android projects's .csproj file fixed the issue for me:
<PropertyGroup>
<IntermediateOutputPath>C:\E</IntermediateOutputPath>
</PropertyGroup>
It writes the intermediate Android files to a folder of your choice - obviously choose a really short one to avoid long paths!
There is another solution that hasn't been mentioned yet: Create a Directory Junction and point it to your solution directory. Place the junction at the root-level, then run the solution from there.
This approach will enable you to workaround the MAX_PATH issue without having to move your project or upgrade to Windows 10.
For example, let's say you store all your code in C:\dev, all your repos in C:\dev\repos, all your Git repos in C:\dev\repos\git, all your Xamarin Git repos in C:\dev\repos\git\xamarin, and all the mobile apps you've built for your largest client in C:\dev\repos\git\xamarin\isis (hey it's not my place to judge). Your latest project can be found in C:\dev\repos\git\xamarin\isis\satellite-tracker\src, but you can't get it to build because the path is too long.
So we create a new directory, C:\J, which will hold this and any other junctions we create for this workaround on other projects. Then open a command prompt as Administrator and navigate to C:\J. Then enter the following command:
mklink /J SatTrack C:\dev\repos\git\xamarin\isis\satellite-tracker\src
Now you can access your solution file from C:\J\SatTrack. If you open it from there, Visual Studio will use that path instead of the longer one and you should be fine after a clean/rebuild.
A simple solution that works great is changing the build output folder in Android Project -> Properties -> Build -> Output path

.exe file not recognized after resigning the manifest on ClickOnce Publish

I am using MVS 2015 with .Net Framework 4.5.
I publish my C# WF Application, everything is fine, but I have to obfuscate the .exe from Application Files.
After I do it, obviously, the setup does not recognize anymore the .exe, the hashes are different and so on.
I resign the new .exe added file with Signtool providing the necessary .pfx and password, then I use Mage to update the .manifest and the .application according to the second part of this MSDN documentation.
Everything is successful, but when I run the setup and I hit install, after a while (around 80% of the installation progress) I receive an error that says that there is something wrong with the new .exe file:
PLATFORM VERSION INFO
Windows : 10.0.16299.0 (Win32NT)
Common Language Runtime : 4.0.30319.42000
System.Deployment.dll : 4.7.2556.0 built by: NET471REL1
clr.dll : 4.7.2633.0 built by: NET471REL1LAST_C
dfdll.dll : 4.7.2556.0 built by: NET471REL1
dfshim.dll : 10.0.16299.15 (WinBuild.160101.0800)
SOURCES
Deployment url : file:///E:/share/myApp.application
Application url : file:///E:/share/myApp.exe.manifest
IDENTITIES
Deployment Identity : myApp.exe.application, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6500754c4a44ec95, processorArchitecture=msil
Application Identity : myApp.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6500754c4a44ec95, processorArchitecture=msil, type=win32
APPLICATION SUMMARY
* Installable application.
ERROR SUMMARY
Below is a summary of the errors, details of these errors are listed later in the log.
* Activation of E:\share\myApp.application resulted in exception. Following failure messages were detected:
+ Exception occurred loading manifest from file myApp.exe: the manifest may not be valid or the file could not be opened.
+ Cannot load internal manifest from component file.
COMPONENT STORE TRANSACTION FAILURE SUMMARY
No transaction error was detected.
WARNINGS
There were no warnings during this operation.
OPERATION PROGRESS STATUS
* [24.03.2018 11:03:32] : Activation of E:\share\myApp.application has started.
* [24.03.2018 11:03:32] : Processing of deployment manifest has successfully completed.
* [24.03.2018 11:03:32] : Installation of the application has started.
* [24.03.2018 11:03:33] : Processing of application manifest has successfully completed.
* [24.03.2018 11:03:35] : Found compatible runtime version 4.0.30319.
* [24.03.2018 11:03:35] : Request of trust and detection of platform is complete.
ERROR DETAILS
Following errors were detected during this operation.
* [24.03.2018 11:03:43] System.Deployment.Application.InvalidDeploymentException (ManifestLoad)
- Exception occurred loading manifest from file myApp.exe: the manifest may not be valid or the file could not be opened.
- Source: System.Deployment
- Stack trace:
at System.Deployment.Application.Manifest.AssemblyManifest.ManifestLoadExceptionHelper(Exception exception, String filePath)
at System.Deployment.Application.Manifest.AssemblyManifest.LoadFromInternalManifestFile(String filePath)
at System.Deployment.Application.DownloadManager.ProcessDownloadedFile(Object sender, DownloadEventArgs e)
at System.Deployment.Application.FileDownloader.DownloadModifiedEventHandler.Invoke(Object sender, DownloadEventArgs e)
at System.Deployment.Application.FileDownloader.OnModified()
at System.Deployment.Application.SystemNetDownloader.DownloadSingleFile(DownloadQueueItem next)
at System.Deployment.Application.SystemNetDownloader.DownloadAllFiles()
at System.Deployment.Application.FileDownloader.Download(SubscriptionState subState, X509Certificate2 clientCertificate)
at System.Deployment.Application.DownloadManager.DownloadDependencies(SubscriptionState subState, AssemblyManifest deployManifest, AssemblyManifest appManifest, Uri sourceUriBase, String targetDirectory, String group, IDownloadNotification notification, DownloadOptions options)
at System.Deployment.Application.ApplicationActivator.DownloadApplication(SubscriptionState subState, ActivationDescription actDesc, Int64 transactionId, TempDirectory& downloadTemp)
at System.Deployment.Application.ApplicationActivator.InstallApplication(SubscriptionState& subState, ActivationDescription actDesc)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl, Uri& deploymentUri)
at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivationWithRetry(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)
What am I doing wrong? What am I missing? :(
I have investigated Marko application, and if you have in use .NET Refactor and have a problem from above here is workaround for get it working:
.Net Reactor has a Visual Studio Add-In that needs installed and configured in the project
Anti ILDASM from .Net Reactor (option that's enabled by default) has to be disabled when obfuscating so that MVS could do the proper packing process
Anyway, if you gonna modify your assemblies after publish you need to recompute hash anyway. How it's possible:
Don't use a Visual Studio publish engine and generate you
application by "mage.exe". It's let to you prepare you source
application first and create ClickOnce application after.
Download utility from second download link [here]. Execute and [Choose] your folder > Change action to [Update] > and [Build]. No more actions required. Update operation will recompute hashs.
If your obfuscator software supports command line parameters then you can add "Post-build event" script in your .exe VS project properties and it will be executed before clickonce build.
"Deploying Obfuscated Assemblies" article you can found here: Securing ClickOnce Applications

Internal.Cryptography.CryptoThrowHelper.WindowsCryptographicException

I'm getting the following error message from Visual Studio 2017 on first run of the ASP.NET Core MVC Boilerplate template (DotNet Core) regarding the SSL certificate:
"Internal.Cryptography.CryptoThrowHelper.WindowsCryptographicException
occurred HResult=0x80070002 Message=The system cannot find the
file specified Source=
StackTrace: at
Internal.Cryptography.Pal.CertificatePal.FromBlobOrFile(Byte[]
rawData, String fileName, String password, X509KeyStorageFlags
keyStorageFlags) at
System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String
fileName, String password, X509KeyStorageFlags keyStorageFlags) at
Microsoft.AspNetCore.Hosting.KestrelServerOptionsHttpsExtensions.UseHttps(KestrelServerOptions
options, String fileName, String password) ... "
All other projects using SSL work fine and I've double checked that my localhost certificate is in the Trusted Root Certification Authorities for my local machine and has not expired.
The project is running IISExpress - perhaps it's not looking the correct place? I'm not sure. Any ideas where I'm going wrong?
Recently had this same issue with ASP.NET Core MVC Boilerplate.
Close Visual Studio, right click on it, "Run as Administrator". Worked for me.
One of two problems is going on.
1) The file "exists", but is a symlink. That tends to confuse the underlying system. (The response is to do File.ReadAllBytes and use the byte[] constructor).
2) The file doesn't exist.
To help diagnose #2 you can read Environment.CurrentDirectory to know where "here" is, and use Directory.EnumerateFiles() to see what is present in the directory and why your file doesn't exist.
Of course, if you didn't think you were loading by file, but thought you were loading from a certificate store: Check your configuration and try again... since you're loading from file :).
If you're running in docker, another workaround is doing a copy at startup.
# The copy is done, because wildcard_certificate.pfx is put into the container using docker secrets, which makes it a symlink.
# Reading a certificate as a symlink is not supported at this moment: https://stackoverflow.com/q/43955181/1608705
# After doing a copy, the copied version is not a symlink anymore.
ENTRYPOINT (IF EXIST "c:\certificates\wildcard_certificate.pfx" (copy c:\certificates\wildcard_certificate.pfx c:\app\wildcard_certificate.pfx)) && dotnet webapplication.dll
My application runs in the "c:\app" folder and I put my "to be copied" certificates in "c:\certificates". At startup the certificate is copied to "c:\app", which my environment variables point to.
version: "3.7"
services:
webapplication:
image: ({CONTAINER_REGISTRY})/webapplication:({LABEL})
environment:
- ASPNETCORE_URLS=https://+;http://+
- ASPNETCORE_HTTPS_PORT=443
- ASPNETCORE_Kestrel__Certificates__Default__Path=wildcard_certificate.pfx
secrets:
- source: config_secrets
target: C:/app/appsettings.json
- source: wildcard_certificate_pfx
target: c:\certificates\wildcard_certificate.pfx
Context
I'm setting up a new dotnet 6 mvcapp website and trying to install Certbot generated certificate locally. The settings for kestrel to load certificate from file was simple enough but I keep getting above errors.
Reason for that like someone has mentioned, the fullchain.pem is actually a symlink or in other word: a shortcut.
Solution for that is to right click on the '.pem file' shortcut and select Open file location and then get the actual .pem files.
Updating your settings to point to the actual files and you should be ok.
Wrong path points to live folder
"Certificates": {
"Default": {
"Path": "C:\\Certbot\\live\\{my domain}\\fullchain.pem",
"KeyPath": "C:\\Certbot\\live\\{my domain}\\privkey.pem"
}
}
Correct path points to archive folder
"Certificates": {
"Default": {
"Path": "C:\\Certbot\\archive\\{my domain}\\fullchain.pem",
"KeyPath": "C:\\Certbot\\archive\\{my domain}\\privkey.pem"
}
}
I've just spent all morning fixing this error....
I'm using the Azure.Security.KeyVault.Certificates nuget package to download a certificate from a KeyVault and use it for IdentityServer.
I recently updated nuget packages for our project so refactored a bit of code, deleting the key bit of the jigsaw.
var signingCertificate = certificateClient.DownloadCertificate(new DownloadCertificateOptions(signingCertificateName)
{
KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.MachineKeySet,
});
X509KeyStorageFlags.MachineKeySet is the secret sauce to getting it running on Azure. I tried several other options before landing back on this one. The annoying thing is, had this in originally before I started refactoring!

Entity framework ".tt" and ".Context.tt" files should be added to ".gitignore"?

I have a project written in C# 6.0 which is using Entity Framework for ORM related operations. We are using git for source control and the following file as .gitignore:
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/
After adding some code to our project using Entity Framework I started to wonder if some of the auto generated files should be added to .gitignore or not. To be more specific, my concern is about .tt and .Context.tt files. I know that this files are auto generated and I remember reading somewhere on SO that these kind of files should not be added to the repository. Right now, I don't really have a problem with these files, but I found really hard to review a pull request when these files keep showing. So, my question is whatever I should or I should not add these file to .gitignore?

Categories