This is something I should really know how to do but I've never figured it out
How can I force Visual Studio to fail a compile based on what would ultimately be compile/syntax errors in ascx/aspx pages?
For example I could put the following into an ASPX page and the site would compile just fine, but obviously fall over if I visited this page;
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<% if (true) { %>
<% if (true) { %>
</asp:Content>
Ah just found this in the "related" questions to the right; How can I compile Asp.Net Aspx Pages before loading them with a webserver?
which links to; http://mikehadlow.blogspot.ie/2008/05/compiling-aspx-templates-using.html
So I've added the following as a post-build event to my project;
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_compiler -v / -p "$(SolutionDir)$(ProjectName)"
and it works like a treat!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With