views:

341

answers:

2

I'm trying to set up my environment for developing, debugging and deploying Windows Desktop Gadgets. I've hit a bit of a roadblock in my project, where I can't run a build on my gadget when the configuration is set to "Debug". If the configuration is set to "Release", the build goes through the following custom tasks:

  1. Copy gadget contents to a seperate folder.
  2. Minify/obfuscate the javascript files, removing comments and whitespace.
  3. Package the files into a CAB file.
  4. Sign the CAB file with a digital certificate.

This runs just fine, my "Debug" configuration has the following tasks defined

  1. Copy gadget folder to AppData\Local\Microsoft\Windows Sidebar\Gadgets\.
  2. Start the gadget using the IDesktopGadget interface.

If I copy those two tasks to the "Release" configuration, they run just fine - no problems whatsoever. I've tried creating a seperate configuration called "Test", copied from the "Release" configuration.

If I try to build any configuration other than "Release", I get an instant message saying "Build succeeded" but no tasks have run at all.

EDIT: I've started a bounty because I still have the same problem with VS 2010 RC and it's very frustrating.

FURTHER EDIT:
Thanks to John I was able to debug the build process. It led me to realize that the <Target> element with condition for debugging was being completely ignored (not even processed). When I swapped the position of my <Target> elements, it worked:

<Target Name="Build" Condition="'$(Configuration)' == 'Release'">
  <!--
      <Obfuscate PathToJasob="C:\Program Files (x86)\Jasob.com\Jasob 3.5" Path="$(GadgetFolder)" Output="$(GadgetName)_obf" log="jasob_log.txt" />
  -->
  <BuildGadget BuildFormat="CAB" Path="$(GadgetFolder)" Target="$(GadgetName).gadget" />
  <SignGadget CertName="Cert1" TimestampURL="http://timestamp.comodoca.com/authenticode" Target="$(GadgetName).gadget" />
</Target>
<Target Name="Build" Condition="'$(Configuration)' == 'Debug'">
  <CopyToGadgets GadgetFolder="$(GadgetFolder)" GadgetName="$(GadgetName)" />
  <RunGadget GadgetName="$(GadgetName)" />
</Target>

So it looks like the second <Target Name="Build"> element overrides the first, despite the Condition attribute being present. What can I do?

+2  A: 

Just a guess:

Your Debug build has its output path set to bin\Release\. The timestamps of the files in bin\Release\ are probably causing MSBuild to conclude that the debug build is already up to date. Try changing the the output path to bin\Debug\ for debug builds.

Joe Gauterin
Thanks, I appreciate the answer even if it was just a guess. Alas, this wasn't the case until I copied the "Release" configuration to the "Debug" configuration in order to try and get it working. I will still change it back, however.
Andy E
+2  A: 

As Joe suggests:

Change your output path like this, and see if that fixes the issue:

<OutputPath>bin\Debug\</OutputPath>

Update

Have you tried running msbuild /verbosity:diagnostic ?

Can you try that and show the output?

Second Update

Make one target 'build', and then make two tasks in that target:

<Target Name="Build">
    <CallTarget Targets="BuildRelease" Condition="'$(Configuration)' == 'Release'" />
    <CallTarget Targets="BuildDebug" Condition="'$(Configuration)' == 'Debug'" />
</Target>

<Target Name="BuildRelease">
    <!--
        <Obfuscate PathToJasob="C:\Program Files (x86)\Jasob.com\Jasob 3.5" Path="$(GadgetFolder)" Output="$(GadgetName)_obf" log="jasob_log.txt" />
    -->
    <BuildGadget BuildFormat="CAB" Path="$(GadgetFolder)" Target="$(GadgetName).gadget" />
    <SignGadget CertName="Cert1" TimestampURL="http://timestamp.comodoca.com/authenticode" Target="$(GadgetName).gadget" />
</Target>

<Target Name="BuildDebug">
  <CopyToGadgets GadgetFolder="$(GadgetFolder)" GadgetName="$(GadgetName)" />
  <RunGadget GadgetName="$(GadgetName)" />
</Target>
John Weldon
As I said in my comment reply to Joe, I had already tried this. In fact, the reason it was set to `bin\Release\` in the first place was due to me copying the Release configuration in an attempt to get it working.
Andy E
Thanks, your reply to Joe wasn't as clear. This clarifies it.
John Weldon
I've updated my answer with a suggestion
John Weldon
@John: Thanks for pointing me in the direction of debugging. I'm pretty new to using VS so I wasn't aware you could do this. I've discovered what the problem is and edited it into my question. Do you have any further ideas? Thanks again :-)
Andy E
@Andy E - Names for the targets need to be unique, so the msbuild parser is probably just dropping the second target named 'Build'.Make 2 targets specific to debug or release, and then update your build target to call either one conditionally on the build type.
John Weldon
@John: Can't thank you enough for your help, it worked perfectly. Thanks a million!
Andy E
You're very welcome
John Weldon