在编译之后但在Build之前,无法在* .csproj中执行自定义代码

时间:2014-01-06 03:11:41

标签: msbuild csproj

从VisualStudio 2010 csproj文件运行时,此代码失败。 请帮忙。

<PropertyGroup>
    <IntelliLockLocation>"C:\Program Files (x86)\Eziriz\IntelliLock\INTELLILOCK.exe"</IntelliLockLocation>
    <IntelliLockProject>"C:\Downloads\intellilock.ilproj"</IntelliLockProject>
  </PropertyGroup>

<Target Name="AfterCompile">
    <Exec Command="$(IntelliLockLocation) -project $(IntelliLockProject) -file &quot;$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)&quot; -targetfile &quot;$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)&quot;" />
  </Target>

1 个答案:

答案 0 :(得分:2)

解决方案是使用自定义Microsoft.VisualStudio.Tools.Office.targets而不会出现问题。

<Import Project="..\Microsoft.VisualStudio.Tools.Office.targets" />
<Target Name="AfterCompile">
    <Exec Command="$(IntelliLockLocation) -project $(IntelliLockProject) -file &quot;$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)&quot; -targetfile &quot;$(ProjectDir)$(IntermediateOutputPath)$(TargetFileName)&quot;  -snkeypair &quot;$(ProjectDir)$(AssemblyOriginatorKeyFile)&quot; -snpassword *****" />
  </Target>