-
Notifications
You must be signed in to change notification settings - Fork 15
Print an error when MvcRazorFilesToCompile is empty #87
Comments
Hi @guylando , I think that the scenario you describe should work. Can you please share your project, or at least the relevant parts of your csproj file? Also, if you can share the generated |
Closing because we don't have enough information to reproduce. |
@Eilon I'm running into this issue too after I've migrated to MSBuild. It worked using project.json tooling. I have a class library with views which I want to precompile and embed into the assembly to consume them in multiple applications. This scenario is similar to what is begin tested in this repo with these projects: The csproj of my class library looks like this: <Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\common.props" />
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<OutputType>Exe</OutputType>
<MvcRazorOutputPath Condition="'$(TargetFramework)'!=''">obj\precompiled\$(TargetFramework)</MvcRazorOutputPath>
</PropertyGroup>
<ItemGroup>
<Content Include="obj\precompiled\**\*" Pack="true" PackagePath="lib\%(RecursiveDir)%(FileName)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="1.1.0" PrivateAssets="All" />
</ItemGroup>
<Target Name="PrecompileRazorViews" AfterTargets="Build" DependsOnTargets="MvcRazorPrecompile" Condition="'$(TargetFramework)'!=''" />
</Project> When I call My
.NET Core version:
|
I was thinking, do the 1.1 runtime packages of this even work with MSBuild tooling? |
I guess the problem is that the
|
@henkmollema Thanks for looking in to this at depth. The @Eilon, we should fail more gracefully when we can't find any cshtml files to compile. Let's use this work item to track it. |
Thanks @pranavkm. That makes sense. |
Is it actually an error to have no CSHTML files? Perhaps a warning would make more sense? |
cc @DamianEdwards for thoughts. |
Yeah, that would be fine. Precompilation is enabled, but no cshtml files were found. Set |
@ajaybhargavb / @pranavkm - @danroth27 just tried publishing a new default Web API project with 2.0 and didn't see any error/warning/anything. Was this maybe fixed by some other change in recent history? |
Wouldn't we want to print a warning though (at least that's what I assumed we wanted to do here) |
When @danroth27 and I were talking, we were wondering if the correct behavior is to be silent. What exactly would we be warning the user about? What would they "fix" to avoid this? Imagine a pure Web API project, which of course has no views, but also has view pre-compilation enabled (because it's enabled by the SDK by default). It doesn't make sense to have a warning in that case, does it? |
I guess that makes sense. Perhaps it's best to get some more feedback to see if it's something people keep running in to and decide accordingly (maybe an MSBuild info log or something along those lines). |
So are we good to close this for now? No warnings/errors are ever shown? |
@pranavkm - can you confirm that's what you're seeing on the latest |
Verified this no longer prints an error. We produce a |
I added the precompilation package and csproj tag and when I publish the main project I get the error:
I have a solution with a couple of projects where the views are separated to a different project than the main project. Does the views precompilation supports such a situation? Is this related to the error?
Do you recognize this error or encountered it before and have a workaround?
The text was updated successfully, but these errors were encountered: