locked
ImportTask not recognized. RRS feed

  • Question

  • Hi,

     I'm fairly new to the details of MSBuild and I'm running into a problem concerning the Import Task.
    We need dev environment specific task to get done with each local build. We don't want these task in Post-Build scripts because they affect people when we say add new references. So here's where I'm at...

    Overriding AfterBuild in our main csprj file like so

    <Target Name="AfterBuild">
        <Message Text="This is the AfterBuild target" Importance="normal" />
        <Exec Command="echo ------------------------------------------------------------------------------" />
        <Exec Command="echo  Moving support files to staging area." />
        <Exec Command="echo ------------------------------------------------------------------------------" />
       
        <Import Project="$(ProjectDir)\Deployment\PostBuild.targets"/>
       
    </Target>

    Throws this...

    Error 100 The "Import" task was not found. Check the following: 1.) The name of the task in the project file is the same as
    the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.)
    The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the
    "C:\Program Files (x86)\MSBuild\12.0\bin" directory...... 


    Am I missing an Assembly reference or something? I'm struggling to find what assembly to Import type exist in and how to add that reference.


    I appreciate your time,
      Travis


    Travis

    Friday, January 17, 2014 11:44 PM

Answers

  • Hi Travis,

    According to the description above, you are trying to modify the .csproj file.

    Do you have a knowledge of the project file schema ?

    How did you define the " Import " task ?

    " Import " is the element in  MSBuild XML schema, we'd better not override it.

    For more details, you can refer to MSBuild Project File Schema Reference and Import Element (MSBuild) .

    If you want to disable the post-build event, you can refer to the answers in the following topics:

    temporarily disable build events in visual studio

    Disable Pre/Post build events

    If you want to change the build order, you can refer to Target Build Order .

    If you want to write custom tasks, you can refer to MSBuild Task Reference and Task Writing .

    If I have any misunderstanding, please feel free to let me know.

    Sincerely,

    Jane.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 20, 2014 2:05 AM
  • You cannot import a task within a target. Move the following line 

    <Import Project="$(ProjectDir)\Deployment\PostBuild.targets"/>

    out of the AfterBuild target.

    Tuesday, January 21, 2014 10:44 AM

All replies

  • Hi Travis,

    According to the description above, you are trying to modify the .csproj file.

    Do you have a knowledge of the project file schema ?

    How did you define the " Import " task ?

    " Import " is the element in  MSBuild XML schema, we'd better not override it.

    For more details, you can refer to MSBuild Project File Schema Reference and Import Element (MSBuild) .

    If you want to disable the post-build event, you can refer to the answers in the following topics:

    temporarily disable build events in visual studio

    Disable Pre/Post build events

    If you want to change the build order, you can refer to Target Build Order .

    If you want to write custom tasks, you can refer to MSBuild Task Reference and Task Writing .

    If I have any misunderstanding, please feel free to let me know.

    Sincerely,

    Jane.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 20, 2014 2:05 AM
  • You cannot import a task within a target. Move the following line 

    <Import Project="$(ProjectDir)\Deployment\PostBuild.targets"/>

    out of the AfterBuild target.

    Tuesday, January 21, 2014 10:44 AM