You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my case, editing the Web.config file and adding the following config line into configuration/appSettings node works:
<addkey="aspnet:RoslynCompilerLocation"value="<full path to packages folder in the solution>\Microsoft.Net.Compilers.Toolset.5.3.0\tasks\net472"/>
Alternatively, using the global NuGet packages (cache?) folder also works:
<addkey="aspnet:RoslynCompilerLocation"value="<full path to userprofile/.nuget folder>\packages\microsoft.net.compilers.toolset\5.3.0\tasks\net472"/>
The second solution requires you to change permissions of the folder <full path to userprofile/.nuget folder>\packages\microsoft.net.compilers.toolset and authorize the IIS_IUSRS group.
You can also edit the csproj file and add the following line into Project/PropertyGroup node in order to prevent the build process copy the roslyn folder into the bin folder:
<RoslynCopyToOutDir>false</RoslynCopyToOutDir>
This step might in fact be required because the tasks defined in Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targets only performs a shallow copy (ignores the l18n folders).
@monoblaine I'm a bit confused about your solution.
If you add the nuget to your project (in this case DNN), and then deploy that project, then adding a web.config would not work since the target system (a normal windows server) would not have a user-profile or nugets.
Oh, @iJungleboy I might have incorrectly assumed that you were also just trying to use the latest Microsoft.Net.Compilers.Toolset for Razor views. I'm sorry if that was not the case. But if that's the case, precompiling the Razor views during the publish should just work.
makes it ignore the built in version and pull in the version from the Microsoft.Net.Compilers.Toolset package (whichever version you use) - but it requires the GeneratePathProperty="true" attribute on the PackageReference.
@CZEMacLeod If, for some reason, you're still using ASP.NET MVC and .NET Framework, migrating to PackageReference is not an option. Even so, I tried adding <RoslynToolPath>..\packages\Microsoft.Net.Compilers.Toolset.5.3.0\tasks\net472</RoslynToolPath> to csproj file and it works. However, if you also want to use the <RoslynCopyToOutDir>false</RoslynCopyToOutDir> option it won't work. You still need to use the Web.config/appSettings configuration.
Activity
monoblaine commentedon Mar 18, 2026
In my case, editing the
Web.configfile and adding the following config line intoconfiguration/appSettingsnode works:Alternatively, using the global NuGet packages (cache?) folder also works:
The second solution requires you to change permissions of the folder
<full path to userprofile/.nuget folder>\packages\microsoft.net.compilers.toolsetand authorize theIIS_IUSRSgroup.You can also edit the
csprojfile and add the following line intoProject/PropertyGroupnode in order to prevent the build process copy theroslynfolder into thebinfolder:This step might in fact be required because the tasks defined in
Microsoft.CodeDom.Providers.DotNetCompilerPlatform.targetsonly performs a shallow copy (ignores the l18n folders).iJungleboy commentedon Mar 18, 2026
@monoblaine I'm a bit confused about your solution.
If you add the nuget to your project (in this case DNN), and then deploy that project, then adding a
web.configwould not work since the target system (a normal windows server) would not have a user-profile or nugets.monoblaine commentedon Mar 18, 2026
Oh, @iJungleboy I might have incorrectly assumed that you were also just trying to use the latest
Microsoft.Net.Compilers.Toolsetfor Razor views. I'm sorry if that was not the case. But if that's the case, precompiling the Razor views during the publish should just work.CZEMacLeod commentedon Mar 18, 2026
I think you can do this a little easier with:
Note the package references above don't have version numbers (when you use CentralPackageManagement), but otherwise work with
The trick is the
makes it ignore the built in version and pull in the version from the
Microsoft.Net.Compilers.Toolsetpackage (whichever version you use) - but it requires theGeneratePathProperty="true"attribute on the PackageReference.monoblaine commentedon Mar 18, 2026
@CZEMacLeod If, for some reason, you're still using ASP.NET MVC and .NET Framework, migrating to
PackageReferenceis not an option. Even so, I tried adding<RoslynToolPath>..\packages\Microsoft.Net.Compilers.Toolset.5.3.0\tasks\net472</RoslynToolPath>tocsprojfile and it works. However, if you also want to use the<RoslynCopyToOutDir>false</RoslynCopyToOutDir>option it won't work. You still need to use theWeb.config/appSettingsconfiguration.CZEMacLeod commentedon Mar 18, 2026
Yes, this was to make it copy the files from the newer compiler. It requires no Web.Config changes.
I use aspnet framework and mvc with PackageReference instead of packages.config without issue, even without switching to Sdk style projects.
Ymmv.
monoblaine commentedon Mar 18, 2026
Thank you, I'll look more into it.
iJungleboy commentedon Mar 19, 2026
@tvatavuk fyi