views:

23

answers:

1

I have setup a Visual Studio project that I have edited to reference the PostSharp build targets. I did not use the MSI installed to install PostSharp on my development machine.

The problem that I am having is that the PostSharp Targets are only executed when I change the build configuration to 'Release', but not in 'Debug'.

I can verify this by looking at the build output which includes the line when in Release:

PostSharp 1.5 [1.5.6.627] - Copyright (c) Gael Fraiteur, 2005-2009.

Looking at the project file, I do not see anything obvious that would suggest PostSharp would run with one configuration and not the other. How can I configure PostSharp to run during both Debug and Release configuration? Keeping in mind, I would rather avoid using the installer.

Karl

EDIT csproj snippent, appears at the bottom of file, below <ItemGroup>:

<PropertyGroup>
    <DontImportPostSharp>True</DontImportPostSharp>
    <PostSharpDirectory>..\..\tools\postsharp-1.5.6.629</PostSharpDirectory>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(PostSharpDirectory)\PostSharp-1.5.targets" />
+1  A: 

Look at the location of the <Import> element in the project file that imports PostSharp.targets. There are normally three <PropertyGroup> elements in the project file. One for general settings, one for Debug only settings and one for Release only settings. Move the <Import> element if it is in the Release group, it should appear after the Import element for Microsoft.CSharp.targets.

Hans Passant
I have defined a 4th PropertyGroup for PostSharp properties, and have the Import tag below the Import of Microsoft.CSharp.Targets. I will edit my question to show what it looks like
Karl
Hans Passant
Thanks for the tip. I was able to track down the problem. I had the build output path set to outside above the project root. I changed it back to the default 'bin\Debug', deleted the bin and obj directories and recompiled. MSbuild was skipping the PostSharp target beecause it thought the output files were up-to-date. The real strange issue here is that this was only a problem on Vista. Win XP, and 2003 Server did not have this problem. Thanks!
Karl