Service Fabric application's root directory - azure-service-fabric

In my code I fail at
if (!File.Exists(_configurationFileName)) {...}
In the immediate window I made a call to Directory.GetCurrentDirectory() and it pointed me to the "work" folder rather than the "code" folder which I would have expected.
Directory.GetCurrentDirectory()
"C:\\SfDevCluster\\Data\\_App\\_Node_0\\My.Application.Type_App2\\work"
So my configuration file which is sitting right next to the executable is of course not being found.
Now I wonder what the solution is.
Since I also want to keep running the console application I don't want to implement any "if service fabric hosting, then change current directory, ..." workaround.
Any recommendations? What about my .exe.config files (if I had any, how would they be found)?
What's the reason for Service Fabric settings the current directory to "work"? Is this some kind of security mechanism?

This is how i just did it change the service manifest to point at the code
<EntryPoint>
<ExeHost>
<Program>configui.exe</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>

You could do some simple reflection and get the folder the executing assembly is in, then reference that file in that location. I did this successfully for an ancillary file I needed that is deployed to the same folder as my executable.
string exePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string filePath = Path.Combine(Path.GetDirectoryName(exePath), "myfilename.txt");

You can select build action as 'content' and select 'copy if newer' in the properties so that it gets copied to the output folder.

Setting "Application Debug Mode" to "Keep Application" resolved a similar issue I was having where my files were not getting copied to the final deploy area on my local service fabric.
It had been set to "Refresh Application" which is in preview as I type this. But that mode wasn't copying my wwwroot folder over, so my view engine (Nancy in this case) was not finding my views.
Right click your service fabric project > properties > Application > Application Debug Mode > Keep Application

Related

Change .vscode folder location

I'm programming a client side applications using SharePoint Designer 2013.
I want to change to VSCODE since it supports a lot of extensions for some Javascript library like angular, jQuery. And because of the Chrome/Node.js debugger extension.
But when I try to start any Debugger, I got the error:
Unable to create 'launch.json' file inside the '.vscode' folder (Error: UNKNOWN: unknown error, mkdir '\\servername\DavWWWRoot\sitename\Style Library\.vscode').
I get this error because it's impossible to create a folder in SharePoint where the name starts with dot.
So there's a possibility to change the name of this folder or the file location to any directory in my local computer?
No, it's not possible to move/rename that folder. VS code is a tool that bases project management on folder content. So it is essential that the project settings reside in the folder being managed.
You can move the "extensions" folder, but unfortunately not the argv.json (so the ".vscode" will, at least be recreated on vscode launch)
https://github.com/microsoft/vscode/issues/17691#issuecomment-559234574
I hope that'll finally change sometime .
https://github.com/microsoft/vscode/issues/3884
https://github.com/OmniSharp/omnisharp-roslyn/issues/953

Original click once update folder location

I have taken over a click once project from a prior developer. How do I find out where his click once update folder was? The properties of the deployed apps only show where the appdata folder is. I need to know the original update location on the click once server so I can redeploy there, but the location that is stored in the project properties is wrong (as are all of the application configuration values) so I must have an old set of source code.
It's a bit of a shot in the dark, but if you have access to a machine that already has the application installed on it and if the application was configured to check for updates before running, you may be able to see the updates location within the app's CDF-MS file installed on that PC. The CDF-MS file is a binary file but you should be able to use STRINGS.exe or visually inspect it to find the beforeApplicationStartup or deploymentProvider value inside the file.
The file is likely located in C:\Users\USERNAME\AppData\Local\Apps\2.0\RANDOM.STR\RANDOM.STR\manifests

IBM Liberty issue

An architect is having issues bringing Liberty up. Currently, an individual is running a server on his local computer and they want to move it to a shared server. When he tries to deploy a simple “helloworld” it’s failing and he is receiving an error “Context Root Not Found”. He is not sure what to set in server.xml file to have wlp recognize the application. They have ODM 8.5 on the mainframe. He thinks it might help if he saw an example of an EAR or WAR file deployed. Any ideas or suggestions?
Either put your application in the dropins folder, it will be detected and started automatically, or put it in the apps folder and configure in server.xml like this:
<webApplication id="HelloApp" location="HelloApp.war" name="HelloApp"/>
by default context root is application file name without extension, but you can change it by adding contextRoot="mycontext" attribute.

Restricting access to particular URL for sesame server deployed on JBoss (WildFly 8.2)

I have a sesame server running deployed in a WildFly 8.2.0 final container.
How can I restrict access to some particular URLs?
I know I have to edit some XML files (deployment descriptor and some other files) but I don't know which files and where to find them.
I figured it out my self.
Step 1:
Open the openrdf-sesame.war with Total Commander or any file archiver. Go the WEB-INF folder and open the web.xml file.
Edit the web.xml file by adding constraints, roles and the login-config tag as in this example : http://www.rivuli-development.com/further-reading/sesame-cookbook/basic-security-with-http-authentication/
Save the edited file within the archive and redeploy the openrdf-sesame.war file containing the modified web.xml file.
Step 2:
Go to the WildFly folder and enter the bin directory and run the add-user.bat file.
Choose b) Application User and hit Enter.
Enter a username and a password for the new user.
When you are asked "What groups do you want this user to belong to?", type in one of the roles you have created in the web.xml file and hit Enter.
When asked “is this new user going to be used for one AS process to connect to another AS process?” type “yes” and hit Enter.
And that's all.
You now have youre particular URL's restricted.

ClickOnce and mageUI adding custom file folder problems

What I do: Publishing .Net 3.5 application via VS, or msbuild (whatever), and now I need to insert to the published application separate directory (Modules - not added as a reference to the project - our project architecture does not allow this). So I'm copying the folder to published location then runs mageUI.exe select the application manifest and then the problems starts. As I press the populate button it's adding also hidden directory? So I remove the directory, after I want to save the manifest file I get the
"Warning MSB3110: Assembly 'NAME.Shell.application.deploy' has mismatched identity 'NAME.Shell.application', expected file name: 'NAME.Shell.application.application'".
Did you have the same problems, according to http://smartclient.codeplex.com/Project/Download/FileDownload.aspx?DownloadId=5060 it should be easy as 1-2-3 but it's not.
On the irony side, I am currently updating the SCSF documentation for ClickOnce deployment for .NET 4.0, and now I know exactly what the problem it.
First, you want to publish to a disk location, not directly to the webserver. So do that, and then copy the dll's you want to add to the deployment into the version folder with the application manifest (.manifest). Rename them yourself -- just add .deploy on the end.
Bring up MageUI and open the application manifest in that folder, then uncheck the box that says "add .deploy to the file names". Click "populate".
Then remove the deployment manifest from the list; it's called something like appname.application. You don't want it to be included in the manifest's list of files.
Now you can save and sign the application manifest. Then without exiting mageUI, open the deployment manifest that is in the root folder (NOT the one in the version folder). Click on "Application Reference", then click Select Manifest. Dig down to the application manifest in the version folder that you just signed and select it. Then just save and sign the deployment manifest. It puts a relative path in there, so if you modify the .application file in the version folder, it won't work right when deployed.
Now take that .application file from the root folder and copy it into the version folder (replacing the one that's there) so you have the right copy for that version in case you need it later.
Now copy the whole shebang out to the webserver. it should work.
I think you are saying you need to add a folder of stuff to your ClickOnce deployment? What exactly are you adding? You say modules -- are they going to be compiled in, or is it something else?
If you want to add files to the deployment you have already created, you need to use MageUI to edit the application manifest, which is called something like appname.exe.manifest. (The appname.application is actually called the deployment manifest, which is confusing but true.) After adding the files, you will need to re-sign the deployment manifest as well (assuming you signed it in the first place).
It would be easier just to add what you want included to your project and re-publish. Depending on what it is, you can set the build action to 'content' (jpegs, html, etc) or 'none' (dll's) and then set "copy to output directory" to true, and it will include it in your deployment.
I'm not sure exactly what you are including. Give me more info, and I can provide more specific help.
RobinDotNet