Skip to content

Commit 07faa28

Browse files
committed
Updating documentation
1 parent e512287 commit 07faa28

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# MSBuild Razor Compiler
23

34
[![Build status](https://ci.appveyor.com/api/projects/status/yndlxwfnxom60n1s?svg=true)](https://ci.appveyor.com/project/MRCollective/msbuildrazorcompiler)
@@ -33,7 +34,20 @@ For intellisense to work it's recommended you add the following to the top of yo
3334

3435
By default, your `.cshtml.cs` files will be nested under their `.cshtml` counterparts this using the [File Nesting feature in Visual Studio](https://docs.microsoft.com/en-us/visualstudio/ide/file-nesting-solution-explorer?view=vs-2019) if your project is classified as an ASP.NET Core project.
3536

36-
If you have a console app or class library you can trick it by ensuring your `.csproj` file starts with `<Project Sdk="Microsoft.NET.Sdk.Web">`.
37+
If you have a console app or class library you can trick it by ensuring your `.csproj` file starts with `<Project Sdk="Microsoft.NET.Sdk.Web">`. There are a couple of automatic behaviours you need to opt-out of though if you do that.
38+
39+
Either way you should add the following to the `.csproj`:
40+
41+
```xml
42+
<PropertyGroup>
43+
<PreserveCompilationContext>true</PreserveCompilationContext>
44+
<RazorLangVersion>3.0</RazorLangVersion>
45+
<RazorCompileOnBuild>false</RazorCompileOnBuild>
46+
<RazorCompileOnPublish>false</RazorCompileOnPublish>
47+
</PropertyGroup>
48+
```
49+
50+
### Console app
3751

3852
Note: if you have a console app that means you'll need to add a `launchsettings.json` file in your `Properties` folder with something like this so that F5 still launches the app rather than IIS Express:
3953

@@ -46,3 +60,19 @@ Note: if you have a console app that means you'll need to add a `launchsettings.
4660
}
4761
}
4862
```
63+
64+
### Class library
65+
66+
You should add the following to the `.csproj`:
67+
68+
```xml
69+
<PropertyGroup>
70+
<OutputType>Library</OutputType>
71+
</PropertyGroup>
72+
```
73+
74+
And add a `launchsettings.json` file in your `Properties` folder with something like this so that F5 doesn't launch IIS Express (it will fail, but it's meant to - it's a class library):
75+
76+
```json
77+
{}
78+
```

0 commit comments

Comments
 (0)