MSDeploy runCommand using relative path

前端 未结 2 1781
臣服心动
臣服心动 2020-12-31 06:07

I am trying to run a command as a part of my packaging/deployment process via MSDeploy. In particular, I am trying to create a custom event log by running installut

相关标签:
2条回答
  • 2020-12-31 06:31

    I realize this isn't the answer you probably wanted to hear but this is how I got around it.

    We created a powershell script on the destination server. So instead of running your command:

    installutil C:\inetpub\wwwroot\MyTestApp\bin\BusinessLayer.dll ... etc
    

    We would run:

    c:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe d:\powershell\installSites.ps1 siteName <NUL
    

    The "sitename" is being passed in as a param into the powershell script. Inside the script it knows on that destination server which files to install, any commands that need to run, app pools to recycle, etc.

    Again, not as easy as finding a relative path, but it does the job.

    0 讨论(0)
  • 2020-12-31 06:34

    You can add definition of DeploymentDir to the .csproj with the action you wrote above:

    <PropertyGroup>
    <DeploymentDir Condition="'$(Configuration)'=='Release' AND '$(DeploymentDir)'==''">Release Deployment Dir</DeploymentDir>
    <DeploymentDir Condition="'$(Configuration)'=='Debug' AND '$(DeploymentDir)'==''">Debug Deployment Dir</DeploymentDir>
    <DeploymentDir Condition="'$(DeploymentDir)'==''">C:\inetpub\wwwroot</DeploymentDir>
    <AplicationName Condition="'$(Configuration)'=='Release' AND '$(AplicationName)'==''">NewTestApp</AplicationName>
    <AplicationName Condition="'$(Configuration)'=='Debug' AND '$(AplicationName)'==''">MyTestApp</AplicationName>
    <ApplicationDeploymentDir Condition="'$(ApplicationDeploymentDir)'==''">$(DeploymentDir)\$(ApplicationName)\bin</ApplicationDeploymentDir>
    </PropertyGroup>
    

    Theese conditions will allow to change everything from command line to take full control over the build process in your build system or script.

    MSBuild.exe yourproj.proj /p:Configuration=Release /p:DeploymentDir=D:\package /p:ApplivationName=BestAppForever
    

    And inside of your task you can use it

    <ItemGroup>
      <MsDeploySourceManifest Include="runCommand">
        <path>installutil $(ApplicationDeploymentDir)\BusinessLayer.dll</path>
      </MsDeploySourceManifest>
    </ItemGroup>
    
    0 讨论(0)
提交回复
热议问题