1
votes

I am trying to create a startup script to register a DLL before running a Fabric Service. I found this article https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-cloud-services-migration-worker-role-stateless-service#startup-tasks which say I need to create a Startup.bat file and config it in ServiceManifest.xml file.

Question: where do I put the Startup.bat file? Can it be a powershell script file instead of .bat file?

1

1 Answers

1
votes

Question: where do I put the Startup.bat file?

You could add the Startup.bat file in the root of your project. In Visual Studio, the Copy to Output Directory property for your startup batch file should be set to Copy Always. More details you could refer to the screenshot.

Can it be a powershell script file instead of .bat file?

Based on my test that Windows PowerShell scripts cannot be called directly , but it can be invoked from within a startup batch file. PowerShell (by default) does not run unsigned scripts. Unless you sign your script, you need to configure PowerShell to run unsigned scripts. To run unsigned scripts, the ExecutionPolicy must be set to Unrestricted.

PowerShell -ExecutionPolicy Unrestricted .\startup.ps1 >> "c:\tom\startup.txt" 2>&1

enter image description here

Service manifest file:

<SetupEntryPoint>
   <ExeHost>
        <Program>Startup.bat</Program>
    </ExeHost>
</SetupEntryPoint>

enter image description here