Msix, packaging and task scheduler - c#

I made a console app using .NET 5.0 in VS2019 pro preview , packaged it with "Windows application packaging project" msix. Everything going smoothly and installed correctly, updates perfectly. Problem arises when I want to add this program to a task scheduler as the .exe file is located in C:\Program Files\WindowsApps\PackageName\Version...
1. Can't run it from the WindowsApps folder due to restrictions (As there are going to be multiple other users it's not feasible to make them all gain access).
2. The folder will change name if I push an update given the version nr.
Is there a way to do this correctly? Like a command to launch windows app files? Any help would be appreciated!

Have you tried defining an execution alias and specifying the alias name (not path) as target for the scheduled task?
This should solve both the permission and changing paths problem.

Related

How to build a WPF app so everyone can install and use it

I am entangled in how to work so that after I finish building the wpf app, I can give it to another computer by downloading the app (for example, downloading the .exe file). I also tried it, but when I ran the .exe file, it only showed a popup cmd and then disappeared. Then I have pulish with self-contanied deployment mode. Here is an image of the following files when I published at bin\release:
Path: C:\Users\ASUS\Source\Repos\UserService\WpfApp1\bin\Release\netcoreapp3.0\publish
If I run the .exe file in a folder then run normally. But when I copy it to a deskop and run it is still the same (can't run).
I want to ask how can I help my app to be used by other computers. Thank you mn! Forget more, my app is using .net core 3.0 already.

Publishing C# application with VisualStudio

I have an application written in C# using VisualStudio 2015 and I want to publish it (eg give an exe or installer to somebody to use it on its PC). From VisualStudio there is possibility to click "publish" in solution explorer. The result files are:
-Application files (File folder)
-project.application (Application manifest)
-setup.exe (Application)
As far as I know "manifest" file should be some metadata, but I can execute that file and it gives me an installer (the same as setup.exe). After installing it runs an application (just like setup.exe). It makes me confused - what exactly project.application is? Can I delete it and use only setup.exe? What is the correct way of publishing an app? One last thing: why does the installer run installation on first execution and run an application on any other? I would expect to run installation any time (just like other software).
Thanks
It sounds like a ClickOnce application. See the following link for more information:
ClickOnce security and deployment
In a nutshell:
The installer copies the files to the users AppData and then runs the application.
There are also other options such as checking for updates from a network location or web address. Then when you run the application it checks for updates and uses the manifest to do an incremental update of the application files.

How can I add window Service in C#/ install it and Run exe(My Job.exe) through this Window Service?

Actually I want to run exe file(My Job.exe) Through window Service in C# but window service should be started automatically when I start the Computer?
I have already added Window Service (MyService) manually. I have also setup project of My application where I also added this service so that I can also be installed when I install my Application.
I have serviceInstaller1 with property
StartType=Automatic;ServiceName=MyService.
I also have serviceProcessInstaller1 with Property
Account=LocalSystem;
When I run this my Applicationo gets installed but MyService don't get installed and I also not see it in Service of Computer Management.
Could any body please help me I already spend two days on it but not finding proper guidline. thanks in Advance.
How is your application being installed? Did you create an installer (.msi file) for it? It sounds like you're trying to implement your own installer instead of using existing tool to do this.
I recommend Advanced Installer. It is a very powerful installer generator and has all the features you need in the free version, and more importantly, it's very easy to use. This tool lets you create an install wizard with the ability to patch and uninstall your software (including services, registry values, files, etc).
I recently have one project with windows service in VS2010 and .Net 4.5 and user OS will be Windows Server 2008. I was unable to create fully functional installation a long time, and still i dont have, but request are changed so no need for installation file. But i can give you advice "How to do".
If you don't have purchased version of InstallShield you need to find some other program for creating installation file.
For installation you need just to copy you .exe output of service and one batch file witch will have next content:
#ECHO off
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" "%~dp0%<filename>.exe"
pause
and then you need to run with administration rights this batch file.
Both files (.exe and .bat) must be in same folder.
You can delete pause command but then you will not see if registration of service was successfully.
Make sure that you have installed target .NET Framework on PC.
I hope that this will help you.
If you just need to run your exe file(My Job.exe) when the system starts up you could add your exe to the Windows Task Scheduler.
Is there any specific purpose for using a Windows service?
The reason that I am saying this is that you have a wide variety of options to invoke you exe as follows
Schedule based on common recurring events, i.e. When the computer starts or When a user logs on.
Schedule based on the calendar, i.e. Daily, Weekly, Monthly, or One time.
Advanced options like execution based on events, etc.

WPF application for Client Execution

I have created a simple inventory application in WPF. How should I give it to client now ?
One way what I did: I have set my AppPresentation solution as start up project and I can see all the DLLs from other solutions are added in the Debug and Release directory of this solution.
When I copy the Release folder to other drive (from D: to C:) and run the AppPresentation.exe some Error occurs about some DLL missing but I can still see those DLLs in this folder.
However when I copy the debug folder to the other drive and run the application i.e. AppPresentation.exe now I can run the application successfully with complete working.
Can I give this entire Debug folder to the client and expect that it runs perfectly on his machine ? I will ensure .NET 4.0 Framework is installed on that machine (but not Visual Studio ofcourse). Will this work ?
It will work as long as you have the required version of the .NET Framework installed on the client and all the necessary dll's have been included,
Ideally you should look at creating a Visual Studio setup project:
Using a setup project has the following advantages:
All your dll's and other files required for the application to run will be consolidated in one setup file
You can specify prerequsites such as .NET Framework which will prevent installation until all the required components have been installed first.
Users can specify exactly where on disk the application should be installed without manually copying the dlls (as would be the case in your scenario).
This is but a few advantages of using a setup project but hopefully you'll be convinced to give it a try as it is the preferred way of installing Windows applications
P.S If your setup project gets more complex consider looking at Wix

MSI not running the current version of the code in .NET Setup project

I'm not sure what happened, but my installer is in a weird state--when I install my MSI, it doesn't seem to be running the current version of the code (I'm using Custom Actions). I verified it by placing some MessageBox.Shows and sure enough, they are not popping up.
It's possible I may have had a few unsuccessful installs previously which may have put the installer in a bad state...but how do I go about resolving this?
Thanks...
If you think you are running older copies of your .msi code, the best way to resolve it is to delete all files from your %temp% directory (type "%temp%" in the windows explorer address bar and you'll see the contents of this directory and delete everything, then try again.)
You shouldn't expect MessageBox.Show to work in a .NET custom installer action. Those actions run in the context of the Windows Installer service, which doesn't run on the interactive desktop. Try logging to the event log (or any other I/O operation that doesn't depend on the current windows desktop and doesn't require an administrative or current-user security token) if you want to debug your custom action.

Categories

Resources