1

I want an MSBuild task to run after the Designer.cs files have been generated (but before the actual C# compiling). Some of the Visual Studio tools still don't put headers on their public members and these items kick out during the compile and masking other, more serious issues. I'm building a package that will inject #pragma statements into the designer files so they don't issue the useless warnings. I have a target that looks like this:

<Target AfterTargets="???????"
                BeforeTargets="CoreCompile"
                Name="BuildTask">
    <IgnoreGeneratedFilesBuildTask IntermediateOutputPath="$(IntermediateOutputPath)"
                               ProjectPath="$(ProjectDir)"/>

But I don't know what to put in the 'AfterTargets' in order to run the task at the right time.

Quark Soup
  • 4,272
  • 3
  • 42
  • 74
  • This may have to be something that is an extension package (VSIX), not an MSBuild task. Visual Studio generates the .Designer files internally outside of MSBuild. At least thats what I think you are getting at. The files are re-generated each time the designer changes and is saved, so your task would have to run hooked on the file/save for the particular designer and run after the code generation but before the designer is closed. Its a lot different in VS2015 with Rosyln. – Ron Beyer Aug 21 '15 at 22:21
  • By different I mean how the code is compiled, not generated. – Ron Beyer Aug 21 '15 at 22:26
  • I suppose that makes sense. The real solution is to rewrite the SettingsSingleFileGenerator so that it generates code that passes the CS1592 errors. I'm not into that but I do have something that can write a quick set of #pragma statements before the *.Designer.cs code is compiled. Too bad. – Quark Soup Aug 22 '15 at 00:22
  • http://stackoverflow.com/questions/526443/globally-suppress-c-sharp-compiler-warnings – Ron Beyer Aug 22 '15 at 00:42
  • @RonBeyer - The link is not very useful. Turning off the warnings for the entire project is not the idea as they are very useful in user written code. The trick here is to turn it off for the automatically generated code only. – Quark Soup Aug 22 '15 at 13:26
  • Are you sure you are trying to suppress CS1592? That is for a malformed XML document tag with an `` element in it, I've never seen auto-generated documentation with that tag? Is this just for settings files? Are you working on VS2008? – Ron Beyer Aug 22 '15 at 15:37
  • @RonBeyer - They are generated in VS2015 when settings files are made public. Rather than trying to put the cart-before-the-horse, I made the settings file 'internal' and exposed the settings I needed through a public class. Not ideal, but more work than it had to be. BTW, we have the same problem again generating XAML for Windows 8.1 code. – Quark Soup Aug 22 '15 at 16:02

0 Answers0