1

When using examples such as

<!--Include in publish-->
  <ItemGroup>
    <None Include="exampleDirectory\**\*.*" CopyToOutputDirectory="Always" CopyToPublishDirectory="Always" />
  </ItemGroup>

This folder has .cshtml and .cshtml.cs files but only the .cshtml.cs files are copied. Is there a specific reason these files do not copy over?

Copy and paste of the required folder into the publish output directory works. Meaning if this copy mechanism just worked and copied all the files this wouldn't be an issue.

I have it setup as <None because I need to have two directories and using <Content gives an error of having two contents being used.

C:\Program Files\dotnet\sdk\3.1.404\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.DefaultItems.targets(318,5): error NETSDK1022: Duplicate 'Content' items were included. The .NET SDK includes 'Content' i
tems from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultContentItems' property to 'false' if you want to explicitly include them in yo
ur project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'dirName\fileName.cshtml'; 'dirName\fileName.cshtml' [C:\path\to\projectName.csproj]

Which when set to false for EnableDefaultContentItems it still does not copy the .cshtml files, just the .cshtml.cs files.

mjwrazor
  • 1,647
  • 1
  • 20
  • 37
  • You mean https://stackoverflow.com/questions/50778521/how-to-disable-precompiled-views-in-net-core-2-1-net-5-for-debugging? – Jeremy Lakeman Feb 10 '21 at 00:47
  • @JeremyLakeman I don't believe so. I am looking for a direct copy of these folders. Doing so the codebase works to present these views which are not connected to RazorPages at all. They are read in with `System.IO.File.ReadAllTextAsync(` – mjwrazor Feb 10 '21 at 15:18

1 Answers1

1

why do you have 'None'?

Example: <ItemGroup> <Content Include="AppData\**" CopyToPublishDirectory="PreserveNewest"/> </ItemGroup>

Ralph Fonz
  • 19
  • 2
  • Updated my question. Also that is an example I have seen, but also using that example still results in only `.cshtml.cs` files being copied. Not `.cshtml` files. – mjwrazor Feb 09 '21 at 22:43
  • for starters try targeting only "~/*.cshtml" not "~/*.cshtml.*" you are targeting every thing while using "*.*" – Ralph Fonz Feb 10 '21 at 16:56