我正试图通过MSDeploy将一个命令作为我的打包/部署过程的一部分运行。具体来说,我正在尝试运行installutil
来对我的DLL之一创建自定义事件日志,但是我在指定从部署目录到DLL的相对路径时遇到了问题。为了开始操作,我在我的csproj中添加了以下配置以生成运行命令提供程序并放入我的清单文件中。请注意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
我遇到的问题是我不想硬编码c:\inetpub\etc的DLL路径。我如何使用从Default Web Site下的部署目录相对路径进行上述调用?理想情况下,我希望MSDeploy获取此路径并将其作为变量传递给runCommand语句,以便找到DLL。然后我可以写像这样的内容:<path>$DeploymentDir\NewTestApp\bin\BusinessLayer.dll</path>
,而无需担心硬编码绝对路径。
是否有任何方法可以在每次使用DLL时不使用绝对路径?