Search code examples
c#asp.netvisual-studiocompiler-errorsweb-publishing

#Define symbol during web publish


I have an ASP.NET web application project that references other C# projects. One of those C# projects has a compiler directive that reports an error if a certain symbol is not defined:

#if (!FOO || !BAR)

   #error "Define symbol for either FOO or BAR"

#endif

When I publish the site, it doesn't define the symbol and, thus, a compiler error results. Is there a way to define a symbol for a referenced project during Visual Studio's publishing process?


Solution

  • One work around is to enable the "Precompile during Publishing" option.

    Screenshot for Visual Studio Publish Web Wizard