https://github.com/StackExchange/StackExchange.Precompilation
Roslyn based csc.exe and aspnet_compiler.exe replacement with metaprogramming hooks for ASP.NET MVC projects from the pre-DNX era
https://github.com/StackExchange/StackExchange.Precompilation
Last synced: 2 days ago
JSON representation
Roslyn based csc.exe and aspnet_compiler.exe replacement with metaprogramming hooks for ASP.NET MVC projects from the pre-DNX era
- Host: GitHub
- URL: https://github.com/StackExchange/StackExchange.Precompilation
- Owner: StackExchange
- License: mit
- Created: 2015-05-18T14:02:17.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-08-10T18:10:03.000Z (over 2 years ago)
- Last Synced: 2025-11-27T14:29:21.318Z (2 months ago)
- Language: C#
- Size: 3.09 MB
- Stars: 157
- Watchers: 33
- Forks: 39
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: license.txt
Awesome Lists containing this project
README
StackExchange.Precompilation
============================
[](https://ci.appveyor.com/project/StackExchange/stackexchange-precompilation/branch/master)
Replacing csc.exe
-----------------
- `Install-Package StackExchange.Precompilation.Build -Pre`
Replacing aspnet_compiler.exe for .cshtml precompilation
--------------------------------------------------------
- `Install-Package StackExchange.Precompilation.Build -Pre`
- Add `true` to your .csproj file (usually replacing the `MvcBuildViews` property)
#### Using precompiled views
- [Add the PrecompiledViewEngine to ViewEngines](https://github.com/StackExchange/StackExchange.Precompilation/blob/fd536b764983e2674a4549b7be6f26e971190c1e/Test.WebApp/Global.asax.cs#L29)
#### Using C# 7 in ASP.NET MVC 5
- [Add the RoslynRazorViewEngine to ViewEngines](https://github.com/StackExchange/StackExchange.Precompilation/blob/fd536b764983e2674a4549b7be6f26e971190c1e/Test.WebApp/Global.asax.cs#L32)
Meta-programming
----------------
- Create a new project
- `Install-Package StackExchange.Precompilation -Pre`
- Implement the ICompileModule interface
- `Install-Package StackExchange.Precompilation.Build -Pre` in the target project
- [Configure your new module](https://github.com/StackExchange/StackExchange.Precompilation/blob/fd536b764983e2674a4549b7be6f26e971190c1e/Test.ConsoleApp/App.config#L8) in the target project's web.config or app.config
Development
-----------
if you have an existing project with StackExchange.Precompilation packages and encounter a bug you can simply:
- pull this repo
- increment semver.txt
- make the fix in the source code
- run BuildAndPack.ps1 (requires a console with VS env vars in your PATH, I recommend powershell with Posh-VsVars)
- setup a nuget source pointing at .\packages\obj
- after that you can update the packages StackExchange.Precompilation in your target project from the packages\obj source
- this gives you local *-local{timestamp} suffixed packages instead of the *-alpha{build} ones produced by the CI build
- PROTIP: if you want to attach an debugger to the compilation of your project or any of the Test.* projects, add a `System.Diagnostics.Debugger.Launch()` statement somewhere in the code ;)
- CI *-alpha{build} packages are available on the stackoverflow myget feed https://www.myget.org/F/stackoverflow/api/v2