[英]MSBuild Task from .csproj File
I Am trying to add a Post Build MSBuild event to my csproj to do this i am trying to call an MSBuild task from inside the Afterbuild target in the.csproj file 我试图将一个Post Build MSBuild事件添加到我的csproj来执行此操作我尝试从.csproj文件中的Afterbuild目标内部调用MSBuild任务
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.-->
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
<Message Text="Copying Files" />
<MSBuild Projects="post.build"
Targets="Copy"
ContinueOnError="false" />
</Target>
This is then the post.build file. 这是post.build文件。
<Project DefaultTargets="Copy"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Copy">
<Message Text="Copying Files inside COPY" />
<CallTarget Targets="CopyToProfile"/> </Target>
</project>
It seems that the csproj cannot call the MSbuild task, can anyone suggest what might be going wrong here. 似乎csproj无法调用MSbuild任务,任何人都可以建议这里可能出错的地方。 I get the error
我收到了错误
error MSB4057: The target "Copy" does not exist in the project.
错误MSB4057:项目中不存在目标“复制”。
So What I eventually got working was. 所以我最终得到的是。
I did as Martin Suggested and 我做了马丁建议和
<Import Project="post.build"/>
However the MSBuild Task still did not function as planned. 但是,MSBuild任务仍未按计划运行。 So I ended up using the
所以我最终使用了
<CallTarget Targets="copy"/>
To Call across the files. 调用文件。 This sounds like it is a limitation in VS2008 and is fixed in VS2010.
这听起来像VS2008的限制,并在VS2010中修复。
Are you sure you haven't made the typo in your actual post.build file as well? 你确定你还没有在你的实际post.build文件中输入错字吗? That is, it should be not .
也就是说,它应该不是。 XML is case-sensitive.
XML区分大小写。
Also, I would double-check that the post.build file is placed in the same folder as the .csproj file. 另外,我会仔细检查post.build文件是否与.csproj文件放在同一个文件夹中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.