Dan*_*eny 49 msbuild msbuild-task visual-studio-2010 visual-studio appharbor
我最近不得不将一些代码从Visual Studio中的PreBuildEvent移动到BeforeBuild目标中,以使其在AppHarbor上运行.在这样做的同时,我也注意到了一个BeforeCompile目标.
这三个看似相似的事件有什么区别:PreBuildEvent,BeforeBuild Target,BeforeCompileTarget?
每个人能做什么/不能做什么,为什么你会选择一个而不是另一个?
Bas*_*ink 91
可以在以下Microsoft.Common.targets文件中找到此问题的答案(取决于您使用的是64位还是32位框架):C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.target对于64位和
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets32位运行时.此文件定义项目构建所经历的所有步骤.引用来源:
<!--
============================================================
Build
The main build entry point.
============================================================
-->
<PropertyGroup>
<BuildDependsOn>
BeforeBuild;
CoreBuild;
AfterBuild
</BuildDependsOn>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
该代码是不够好,解释如何使用的BeforeBuild,并AfterBuild在这两个目标的意见目标.
<!--
============================================================
BeforeBuild
Redefine this target in your project in order to run tasks just before Build
============================================================
-->
<Target Name="BeforeBuild"/>
<!--
============================================================
AfterBuild
Redefine this target in your project in order to run tasks just after Build
============================================================
-->
<Target Name="AfterBuild"/>
Run Code Online (Sandbox Code Playgroud)
接下来是CoreBuild目标的定义:
<PropertyGroup>
<CoreBuildDependsOn>
BuildOnlySettings;
PrepareForBuild;
PreBuildEvent;
ResolveReferences;
PrepareResources;
ResolveKeySource;
Compile;
UnmanagedUnregistration;
GenerateSerializationAssemblies;
CreateSatelliteAssemblies;
GenerateManifests;
GetTargetPath;
PrepareForRun;
UnmanagedRegistration;
IncrementalClean;
PostBuildEvent
</CoreBuildDependsOn>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
所以Build目标只是目标的一个包装器CoreBuild,使您能够在CoreBuild目标之前或之后执行自定义步骤.正如可以在上面所述可以看出PreBuildEvent和PostBuildEvent被列为的依赖CoreBuild目标.Compile目标的依赖关系定义如下:
<PropertyGroup>
<CompileDependsOn>
ResolveReferences;
ResolveKeySource;
SetWin32ManifestProperties;
_GenerateCompileInputs;
BeforeCompile;
_TimeStampBeforeCompile;
CoreCompile;
_TimeStampAfterCompile;
AfterCompile
</CompileDependsOn>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
再次BeforeCompile,AfterCompile并在代码中评论:
<!--
============================================================
BeforeCompile
Redefine this target in your project in order to run tasks just before Compile.
============================================================
-->
<Target Name="BeforeCompile"/>
<!--
============================================================
AfterCompile
Redefine this target in your project in order to run tasks just after Compile.
============================================================
-->
<Target Name="AfterCompile"/>
Run Code Online (Sandbox Code Playgroud)
鉴于此信息,我不知道为什么AppHarbor不支持,Pre-, PostBuildEvent而Build可以使用修改Before-, AfterBuild.
选择Target要覆盖哪个场景取决于您希望执行给定任务的构建期间的时刻.目标对于他们可以完成的任务没有特定的限制和/或好处.除了他们可以适应ItemGroup之前步骤定义/填充的或属性之外.
使用nuget引入包可能最好在构建尝试解决项目依赖项之前执行.因此BeforeCompile,这种行动不是一个好的候选人.
我希望这能够解释这个问题.在MSDN上找到了另一个很好的解释
| 归档时间: |
|
| 查看次数: |
11266 次 |
| 最近记录: |