【发布时间】:2016-02-18 10:55:38
【问题描述】:
当我通过 IIS 导入应用程序时,我想创建一个新的事件日志事件源来记录我的 webAPI 应用程序。
我将我的应用程序发布到 VS2015 中的 web 部署文件夹 (zip) 文件并从中导入。
我找到了这段代码来创建事件源:
if ([System.Diagnostics.EventLog]::SourceExists("myWeb.API") -eq $false) {
[System.Diagnostics.EventLog]::CreateEventSource("myWeb.API", "Application")
}
我可以将它放在 EventSource.ps1 文件中,当我从提示符运行它时,它会执行我想要的操作。
如何在 IIS 导入应用程序 过程中执行此操作?
我尝试过使用 .pubxml 文件,但使用/覆盖/调用它的元素让我感到困惑 - 我尝试过 AfterAddIisSettingAndFileContentsToSourceManifest 和 PipelineDependsOn。
<Target Name="CustomCreateEventSource">
<Message Text="Create Event Source" Importance="high"/>
<PropertyGroup>
<EventSource Condition=" '$(EventSource)'=='' ">
myWeb.API
</EventSource>
</PropertyGroup>
<Exec Command="powershell.exe"
-NonInteractive
-executionpolicy Unrestricted
-file "$(PublishUrl)Publish\EventSource.ps1" "$(EventSource)"" /></Target>
我宁愿它是通过 IIS 导入应用程序完成的,作为一击过程,而不是:
- 导入应用程序
- 运行 powershell
因为它将由非技术用户导入。
非常感谢您抽出宝贵时间提供帮助!
【问题讨论】:
标签: powershell iis webdeploy