我试图通过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>
Run Code Online (Sandbox Code Playgroud)
在调用msbuild之后,这在package.zip中正确生成了我的清单.当我运行MyTestApp.deploy.cmd/Y时,它正确调用了msdeploy并将我的文件部署到inetpub\wwwroot\MyTestApp并从下面的清单中运行我的命令:
<runCommand path="installutil C:\inetpub\wwwroot\MyTestApp\bin\BusinessLayer.dll ... etc
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我不想将此DLL路径硬编码到c:\ inetpub\etc.如何使用默认网站下部署目录中的相对路径进行上述调用?理想情况下,我希望MSDeploy采用此路径并将其作为变量传递给runCommand语句,以便找到DLL.然后我可以编写类似的内容:<path>installutil $DeploymentDir\NewTestApp\bin\BusinessLayer.dll</path>无需担心硬编码绝对路径.
有没有办法这样做,而不是每次都使用我的DLL的绝对路径?