Injecting a target before the build

Hi

I'm modifing a .target file for building .Net 1.0 & .Net 1.1 within VS. As neither versions of csc support the /keycontainer command-line option, I'm trying to inject a target before the build that will check that and emmit a more meaningfull message.
I've tryed both this:

  <PropertyGroup>
    <CompileDependsOn>CheckUnsupportedFeatures;$(CompileDependsOnOn)</CompileDependsOn>
  </PropertyGroup>-->

  <Target Name="CheckUnsupportedFeatures" Condition=" '$(Platform)' == '.NET 1.0' Or '$(Platform)' == '.NET 1.1' ">
    <Error Condition=" '$(SignAssembly)' == 'true' "
           Text="The $(Platform) platform doesn't support strong-name signing within the IDE. Please use the AssemblyKeyFileAttribute instead"/>
  </Target>

and this:

  <Target Name="BeforeBuild">
    <Error Condition=" '$(SignAssembly)' == 'true' And ('$(Platform)' == '.NET 1.0' Or '$(Platform)' == '.NET 1.1') "
           Text="The $(Platform) platform doesn't support strong-name signing within the IDE. Please use the AssemblyKeyFileAttribute instead"/>
  </Target>

but neither of them work. My target isn't called.
Anyone can help

Regards,
Gustavo Guerra



Answer this question

Injecting a target before the build

  • Fast Eddie

     ovatsus wrote:
    Yes, that worked, now when my condition is true, I get my custom error condition.
    But when the condition is false, I get an error saying it can't copy obj\Debug\assembly.exe to bin\Debug\assembly because the file in obj doesn't exists.
    I've sent the new log to you


    Never mind that, dumb mistake, I had CheckUnsupportedFeatures;$(CompileDependsOnOn) instead of CheckUnsupportedFeatures;$(CompileDependsOn).

    Thanks for your help

  • Bhupal

    The $( CompileDependsOn) property should be defined after the import statement. Also $( CompileDependsOn) needs to be before your target and not after.
    Please let me know if this works.

  • KAUAIFINN

    Hi Gustavo,

    Can you send us the diagnostic log out put of your build (msbuild /v:diag)

    Thanks,

    Jay Shrestha
    (Jaysh@microsoft.com)

  • Dataminer101

    I've sent it by mail (Couldn't find a way to attach here)
  • Newbie71

    Yes, that worked, now when my condition is true, I get my custom error condition.
    But when the condition is false, I get an error saying it can't copy obj\Debug\assembly.exe to bin\Debug\assembly because the file in obj doesn't exists.
    I've sent the new log to you

  • Injecting a target before the build