我正在尝试通过 MSDeploy 运行命令作为我的打包/部署过程的一部分。特别是,我试图通过对我的一个 DLL 运行installutil来创建自定义事件日志,但是我无法从部署目录指定 DLL的相对路径。首先,我将以下配置添加到我的 csproj 中,以便在我的 Manifest 文件中生成 runCommand 提供程序。请注意 DLL 的绝对路径。
<PropertyGroup>
<!-- Extends the AfterAddIisSettingAndFileContentsToSourceManifest action to create Custom Event Log -->
<IncludeEventLogCreation>TRUE</IncludeEventLogCreation>
<AfterAddIisSettingAndFileContentsToSourceManifest Condition="'$(AfterAddIisSettingAndFileContentsToSourceManifest)'==''">
$(AfterAddIisSettingAndFileContentsToSourceManifest);
CreateEventLog;
</AfterAddIisSettingAndFileContentsToSourceManifest>
</PropertyGroup>
<Target Name="CreateEventLog" Condition="'$(IncludeEventLogCreation)'=='TRUE'">
<Message Text="Creating Event Log" />
<ItemGroup>
<MsDeploySourceManifest Include="runCommand">
<path>installutil C:\inetpub\wwwroot\MyTestApp\bin\BusinessLayer.dll</path>
</MsDeploySourceManifest>
</ItemGroup>
</Target>
<ItemGroup>
在调用 msbuild 之后,这会在我的 package.zip 中正确生成我的清单。当我运行MyTestApp.deploy.cmd /Y它正确调用 msdeploy 并将我的文件部署到 inetpub\wwwroot\MyTestApp 并从下面的清单运行我的命令:
<runCommand path="installutil C:\inetpub\wwwroot\MyTestApp\bin\BusinessLayer.dll ... etc
我遇到的问题是我不想将此 DLL 路径硬编码到 c:\inetpub\etc。如何使用默认网站下我的部署目录中的相对路径进行上述调用?理想情况下,我希望MSDeploy采用此路径并将其作为变量传递给 runCommand 语句,以便找到 DLL。然后我可以写这样的东西:<path>installutil $DeploymentDir\NewTestApp\bin\BusinessLayer.dll</path>
不必担心硬编码绝对路径。
有没有什么方法可以做到这一点,而无需每次都使用我的 DLL 的绝对路径?