0
我有導入到我的.csproj
文件中的以下目標文件,其中一個目標(AfterAddPostAction)從未觸發。爲什麼不? (抱歉它是如此冗長,但MSBuild的是大便的抽象和CallTask沒有看到設置含有CallTask元件的目標內的屬性值。)爲什麼我的目標沒有執行?
<?xml version="1.0" encoding="Windows-1252"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="EstablishLog">
<MakeDir Condition="!Exists('$(MSBuildProjectDirectory)\Logs')" Directories=".\Logs"/>
<PropertyGroup>
<PowerShellExe Condition=" '$(PowerShellExe)'=='' ">%WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe</PowerShellExe>
<ScriptPath Condition=" '$(ScriptPath)'=='' ">C:\Users\Admin\Documents\GitHub\powershell-scripts\</ScriptPath>
<LogState>$(ScriptPath)ProjectSnapShot.ps1</LogState>
<DoPostAction>$(ScriptPath)postAction-BeforePublish.ps1</DoPostAction>
<Switches>-NonInteractive -executionpolicy Unrestricted</Switches>
<Arguments>"& { &'$(ScriptPath)' } "</Arguments>
</PropertyGroup>
</Target>
<Target Name="AfterClean" DependsOnTargets="EstablishLog">
<PropertyGroup>
<LogFile >AfterClean$(ApplicationVersion).log</LogFile>
<LogFile Condition="Exists('$(MSBuildProjectDirectory)\Logs')">.\Logs\$(LogFile)</LogFile>
<Arguments>"& { &'$(LogState)' } "</Arguments>
</PropertyGroup>
<Exec Command="$(PowerShellExe) $(Switches) -command $(Arguments) > $(LogFile)" />
</Target>
<Target Name="BeforeBuild" DependsOnTargets="EstablishLog">
<PropertyGroup>
<LogFile >BeforeBuild$(ApplicationVersion).log</LogFile>
<LogFile Condition="Exists('$(MSBuildProjectDirectory)\Logs')">.\Logs\$(LogFile)</LogFile>
<Arguments>"& { &'$(LogState)' } "</Arguments>
</PropertyGroup>
<Exec Command="$(PowerShellExe) $(Switches) -command $(Arguments) > $(LogFile)" />
</Target>
<Target Name="AfterBuild" DependsOnTargets="EstablishLog">
<PropertyGroup>
<LogFile >AfterBuild$(ApplicationVersion).log</LogFile>
<LogFile Condition="Exists('$(MSBuildProjectDirectory)\Logs')">.\Logs\$(LogFile)</LogFile>
<Arguments>"& { &'$(LogState)' } "</Arguments>
</PropertyGroup>
<Exec Command="$(PowerShellExe) $(Switches) -command $(Arguments) > $(LogFile)" />
</Target>
<Target Name="BeforePublish" DependsOnTargets="EstablishLog">
<PropertyGroup>
<LogFile >BeforePublish$(ApplicationVersion).log</LogFile>
<LogFile Condition="Exists('$(MSBuildProjectDirectory)\Logs')">.\Logs\$(LogFile)</LogFile>
<Arguments>"& { &'$(LogState)' } "</Arguments>
</PropertyGroup>
<Exec Command="$(PowerShellExe) $(Switches) -command $(Arguments) > $(LogFile)" />
</Target>
<Target Name="AddPostAction" AfterTargets="BeforePublish" DependsOnTargets="EstablishLog">
<PropertyGroup>
<PostAction>FileCopyPDA.FileCopyPDA</PostAction>
<Arguments>"& { &'$(DoPostAction)' '$(PostAction)' $(Configuration)} "</Arguments>
<LogFile >AddPostAction$(ApplicationVersion).log</LogFile>
<LogFile Condition="Exists('$(MSBuildProjectDirectory)\Logs')">.\Logs\$(LogFile)</LogFile>
</PropertyGroup>
<Exec Command="$(PowerShellExe) $(Switches) -command $(Arguments) > $(LogFile)" />
</Target>
<!--This one is never called-->
<Target Name="AfterAddPostAction" DependsOnTargets="EstablishLog;AddPostAction">
<PropertyGroup>
<LogFile >AfterAddPostAction$(ApplicationVersion).log</LogFile>
<LogFile Condition="Exists('$(MSBuildProjectDirectory)\Logs')">.\Logs\$(LogFile)</LogFile>
<Arguments>"& { &'$(LogState)' } "</Arguments>
</PropertyGroup>
<Exec Command="$(PowerShellExe) $(Switches) -command $(Arguments) > $(LogFile)" />
</Target>
<Target Name="AfterPublish" DependsOnTargets="EstablishLog">
<PropertyGroup>
<LogFile >AfterPublish$(ApplicationVersion).log</LogFile>
<LogFile Condition="Exists('$(MSBuildProjectDirectory)\Logs')">.\Logs\$(LogFile)</LogFile>
<Arguments>"& { &'$(LogState)' } "</Arguments>
</PropertyGroup>
<Exec Command="$(PowerShellExe) $(Switches) -command $(Arguments) > $(LogFile)" />
</Target>
</Project>
當日志級別設置爲詳細或診斷時,msbuild日誌文件中的內容是什麼? –
我把它設置爲診斷,並沒有提及'AfterAddPostAction'。甚至不跳過。我發現的是'DependsOnTargets'是不夠的,但'AfterTargets'是。我仍然不明白爲什麼。 –
你正在執行哪個目標作爲「主要」目標?現在我看到了十幾個目標,並且不清楚它們是如何被調用的。 –