csrun loses executable from .csx package - azure

I am having a hard time with a seemingly simple Azure program.
My exercise is to create WorkerRole that spawns "helloworld.exe"
- which does just that - prints "hello world" and exits.
I am using Visual Studio to create a project,
then added new folder to project solution "bin2" where I put hello.exe
using menu option "Add Existing Item".
then created local storage bin2 in ServiceDefinition.csdef:
so I can find my executable with RoleEnvironment:
string baseDir = RoleEnvironment.GetLocalResource("bin2").RootPath.Replace('\', '/');
string command = Path.Combine(baseDir, #"hello.exe");
then ran cspack.exe to create .csx directory.
Resulting .csx package got hello.exe in the correct location:
WorkerRole1.csx\roles\WorkerRole1\approot\bin2\hello.exe
then I started local development fabric with csrun.exe and get error from the parent process that bin2/hello.exe is missing.
Do I need to do something else to make csrun to copy hello.exe into "bin2".
Any ideas?
Thank you in advance,
Ivgard

I'm pretty sure I answered this question already (probably on the MSDN forum)? But the local resource you declare will give you a path entirely different from where you're putting your hello.exe. When you add the file to your project, it gets included with the rest of the code for your role. When you look up the local resource, you get a path to an empty directory which you can use to write and read data. Those two are completely separate and unrelated locations.
If you want to find your hello.exe that's under bin2, just look for the relative path, or use %RoleRoot%\approot\bin2 (or maybe it's %RoleRoot%\approot\bin\bin2?).

Related

How to create an example extension for Hybris 2011 version

I just download the latest 2011.1, and try to use "ant extgen" command to create a default extennsion, but meet following error:
Would anyone know how to deal with it?
extgen.xml:293: The following error occurred while executing this line:
extgen.xml:35: Source directory '${ext.develop.path}' for template 'training' does not exist.
Just run it again and it should work the second time.
There does seem to be a bug in the build scripts that has probably been there a while. I assume that ant extgen was the first thing you ran after unpacking. There is no config folder so the build script did this:
[input] No config folder was found at /path/to/hybris/config.
[input] Please choose the configuration template.
[input] Press [Enter] to use the default value ([develop], production)
and you chose develop
Unfortunately it stores your choice in a variable input.template which is the same name as used when later on the script asks you what extension template you want to base yours on. So the script sees that the variable already has a value and doesn't ask you:
[input] Please choose a template for generation.
[input] Press [Enter] to use the default value (commercewebservices, commercewebservicestests, yacceleratorfulfilmentprocess, yacceleratormarketplaceintegration, yacceleratorordermanagement, yacceleratorstorefront, yaddon, ybackoffice, ycommercewebservices, ycommercewebservicestest, ydocumentcart, [yempty], yhacext, yocc, yoccaddon, yocctests, ysapproductconfigaddon, ysmarteditmodule, yvoid, ywebservices)
It then tries to find a template extension develop and fails.
Running it the second time means your config folder is already generated and it correctly asks you which extension you want to base your extension on.

Suave with netcoreapp2.0

I've been following this Suave tutorial:
https://legacy.gitbook.com/book/theimowski/suave-music-store/details
And in general this looks good. However, I was trying to make it work with Linux and for some reason I was unable to compile it with code when TargetFramework was set to "net461" (Target Framework not found), so I tried changing it to "netcoreapp2.0". It compiled, but I hit a problem later on:
https://theimowski.gitbooks.io/suave-music-store/content/en/css.html
At the end it says to add a WebPart:
pathRegex "(.*)\.(css|png)" >=> Files.browseHome
which fails for me. All compiles, but I get
This page isn’t working
localhost didn’t send any data.
I took a look at Suave's source code and it turned out that "Files.browseHome" searches for a file under "ctx.runtime.homeDirectory".
I noticed that this is set on my machine to:
/home/<my_user_name>/.nuget/packages/suave/2.2.1/lib/netstandard1.6
and obviously, that's not my project directory, so no wonder it couldn't find the file.
My question here is: what shall I do in order to make my Suave app handle my css/png files correctly using Files.browseHome ?
EDIT:
Just found out that replacing the WebPart with:
pathRegex "(.*)\.(css|png)" >=> Files.browse "/home/<my_username>/<path_to_my_project>/bin/Debug/netcoreapp2.0/"
works fine, but it looks ugly. Any idea how to make it better ? Basically I don't want to be forced to hardcode the absolute path anywhere.
I think the answer is to be found in https://suave.io/files.html, which suggests creating a config as follows:
let config =
{ defaultConfig with homeFolder = Some (Path.GetFullPath "./public") }
The path returned by Path.GetFullPath will depend on the current working directory that your app sees when it's started (which will, in turn, depend on how you start the app: from the command line, from a systemd unit file, etc.) There are too many possible variables here for me to be able to give you exact instructions, but if your startup method can cd into an appropriate folder before starting your Suave server, then that should solve your problem.
If you run into difficulties with getting the current working directory set correctly, then you could just hardcode the full path in the config:
let config =
{ defaultConfig with homeFolder = Some "/home/<your_username>/<path_to_your_project>/bin/Debug/netcoreapp2.0/" }
But that's kind of ugly, and not really portable (you'd have to modify that path again once you deploy the app). So I'd recommend the approach of making sure your start script does a cd to the right location, then using Path.GetFullPath with a relative path. Alternately, you could have a config file that gets read in at app startup where you specify the home path, or pass it in as an environment variable... All kinds of possibilities. Just make sure that your code can be handed some information on startup that specifies the correct "home" folder, and then put that in your Suave config as I've shown, and that should solve it.

Access test resources within Haskell tests

This is probably a basic question but I've been Googling for a while on it... I have a Cabal-ized Haskell project and I'm in the process of writing integration tests for it. I want to be able to include test resources for my project in the same repo and access them in tests. For example, here are a couple things I want to accomplish:
1) Check a dummy database instance into my repo, including a shell script that spins up a database process. I want to write an Hspec integration test that spins up the database process, makes some calls to it, and then shuts it down. So I need to be able to find the shell script so I can use System.Process.createProcess on it.
2) Check in paired "input" and "output" files. My test should process each of the input files and compare them to a corresponding output file to make sure they match. (I've read about "golden" but it doesn't seem to solve the problem of finding/reading the input files in the first place?)
In short, how can I go about creating a "resources" folder in the root folder of my Haskell project and find the path to it inside tests?
Have a look at an existing project that uses input and output file.
For example, take haddock, the source code is at https://github.com/haskell/haddock. They have the test files under a folder (https://github.com/haskell/haddock/tree/master/html-test/ref) and they are referenced as extra-source-files in the cabal file (https://github.com/haskell/haddock/blob/master/haddock.cabal). Then the test code (https://github.com/haskell/haddock/blob/master/html-test/run.lhs) uses some CPP macro (__FILE__) to get the current directory, and can then resolve the files relative to that folder.

Calling consecutive DLL's from {tmp} in Inno Setup

I want to use a DLL (lets say 'A.dll'), that I created in Delphi, within my Inno Setup script that uses a bunch of other DLLs ('B.dll', 'C.dll', ...). All these dll-files are included in the Files-section as follows:
[Files]
Source:"libs\*.dll"; Flags: dontcopy
In the code section I declare methods of the used DLL as described in the Online help and add the loadwithalteredsearchpath flag:
procedure MyMethod; external 'MyMethod#files:A.dll,B.dll,C.dll stdcall loadwithalteredsearchpath';
When the installer starts, all needed files are copied into the temporary directory the constant {#tmp} is pointing to. However, MyMethod starts its execution just fine (checked it with some Showmessages), but the whole thing breaks, when the method tries to use the other DLLs.
Next to the temporary folder from {#tmp} two other temporary directories are created during the setup (all with the 'IS-xxxxx.tmp' pattern), which contain 'setup.tmp' (which is not occurent in {#tmp}). When I now manually copy all the DLL's (besides A.dll) into both these other directories at the beginning of the setup, then everything works fine. But when I let it run only as defined in my script, then A.dll doesn't seem to find the other libraries.
Does anybody know, why this is happening and how I can fix this? This seems to be a problem with the PATH, but I thought that Inno Setup adds the tmp-dir into the PATH, so that the setup can find the DLL's (which it does, but strangely only for A.dll).
Thanks in advance for your help! :)
EDIT: The actual error I get, when I use one of the 'foreign' DLL's (B.dll, C.dll, ...) by calling one of their methods inside of A.dll during the Inno Setup:
Access violation at address 00408CC7 in module 'setup.tmp'. Read of adress 00000000.
EDIT 2: I think I realized why my problem is happening: With ExtractFilePath (first link) in my own A.dll I discovered, that the setup.exe is not executed within {tmp} but one of the other two temporary dirs that are creating at the beginning of the setup. It also appears, that not {tmp} but the current working dir (thus the dir, where inno is executed) is added to the library search path (second link). This would explain, why the other libraries (B.dll, C.dll, ...) can only be accessed when manually copying to this other temp dir. I suppose that A.dll is extracted and called from {tmp} without a problem, because it is referred as the "main-library" in the external command. I thought that with loadwithalteredsearchpath the other libraries could remain in the same directory, but that doesn't seem to work.
But how can I fix this now in an nifty way? I think I could copy the DLLs manually to the setup-path (by using ExtractFilePath(ParamStr(0)), after they have been extracted to {tmp} to solve the problem. But this seems to be a dirty workaround as using DLLs in Inno Setup is supposed to work differently.
How to get path where is temporary Inno setup file is located
External function calls with multiple dependent DLLs
Well I'm not sure if you only load the DLLs without registering them in the system registry. However your first EDIT shows an error triggered by attempts to access some stack of the registry, so I assume you are. In that case, I simply use a batch file (which fires commands in the CMD console) to register my DLLs as I would one by one:
#echo off
echo Registering DevExpress DLLs
%~dp0gacutil.exe /i %~dp0DevExpress.BonusSkins.v12.1.dll
%~dp0gacutil.exe /i %~dp0DevExpress.Charts.v12.1.Core.dll
So, I place this in the RUN section of the iss script:
[Run]
Filename:C:\myFolder\RegisterDevExpress.bat"
Hope this helps.

publishing MVC 4 app exception.., The specified path, file name, or both are too long

I am attempting to publish a website, using the file system method. I used this method with visual studio 2010 and I didn't run into to many problems. But I recieved the above error when trying in visual studio 2012. The full error is bellow...
Error : Copying file Service References\ACOServiceReference\FocusedReadMissionsRedux.ACOServiceReference.searchPatientbyDemographicsResponse.datasource to obj\Release\Package\PackageTmp\Service References\ACOServiceReference\FocusedReadMissionsRedux.ACOServiceReference.searchPatientbyDemographicsResponse.datasource failed. The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
What am I missing or doing wrong? Obviously a file path is too long, but is there a way I can create like path variables or something to shorten the path names? How can I set that up?
No you can't shorten it as Windows will use the fully qualified name (C:\aaa\aaa...).
Two solutions:
Shorten your namespace (FocusedReadMissionsRedux.ACOServiceReference.searchPatientbyDemographicsResponse.datasource)
Change the location of your project (ie D:\Code\ProjectOne)
I was able to solve this problem on my project by navigating to the files under the service reference then under Reference.svcmap. Select each one of them and change the build action from Content to none. These files aren't usually needed for the app so they don't need to be published.

Resources