简体   繁体   English

来自.csproj文件的MSBuild任务

[英]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.

相关问题 msbuild / csproj执行任务问题 - msbuild/csproj exec task problem MSBuild nuget 包:要添加到 .csproj 文件中的内容? - MSBuild nuget package: what to add to .csproj file? 如何从 BeforeBuild 任务中的 csproj 文件中删除节点? - How to Remove node from csproj file in BeforeBuild Task? 如何使用MSBuild将链接文件添加到csproj文件。 (3.5框架) - How to add a linked file to a csproj file with MSBuild. (3.5 Framework) MSBuild和CSPROJ:如何调整C#文件的包含/编译 - MSBuild and csproj: how to conditioning c# file inclusion/compiling 如何在.csproj文件中使用MSBuild条件测试编译器指令? - How do I test for compiler directives with an MSBuild Condition in a .csproj file? 在.csproj中包含.targets文件以全局定义项目和MSBuild变量 - Including a .targets file in .csproj to globally define project & MSBuild variables 可以使用MSBuild + .csproj文件创建msi-installer吗? - Can an msi-installer be created using MSBuild + .csproj-file? OmniSharp MSBuild ProjectManager 无法更新 my.csproj 文件 - OmniSharp MSBuild ProjectManager is not able to update my .csproj file 如何以编程方式使用 .net 2.0 MSBuild 构建 csproj 文件? - How to build a csproj file using .net 2.0 MSBuild programmatically?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM