Closed sayedihashimi closed 7 years ago
@cdmihai would you consider this a duplicate of #1026?
More specific issue might be #1622. #1026 is the more general issue.
@sayedihashimi can you please point me to the msbuild snippet that constructs the Content item? Is it coming from a glob?
I saw the expressions by using /pp
when calling msbuild.exe. It looks to be coming from the .targets file below. I've also included the first snippet itself for Content.
<!--
============================================================================================================================================
<Import Project="$(MSBuildThisFileDirectory)..\build\netstandard1.0\Microsoft.NET.Sdk.Web.ProjectSystem.props" Condition="Exists('$(MSBuildThisFileDirectory)..\build\netstandard1.0\Microsoft.NET.Sdk.Web.ProjectSystem.props')">
C:\Program Files\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk.Web.ProjectSystem\build\netstandard1.0\Microsoft.NET.Sdk.Web.ProjectSystem.props
============================================================================================================================================
-->
<!-- Publish everything under wwwroot, all JSON files, all web.config files and all Razor files -->
<Content Include="wwwroot/**" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExclude
Ah, I remember now. We have a unit test for this exact behaviour: https://github.com/Microsoft/msbuild/blob/master/src/Build.OM.UnitTests/Definition/ProjectItem_Tests.cs#L773
When we were fixing the globbing code to work crossplat we found this behaviour where the slash of the fixed directory part was blindly prepended to the expanded wild card part. We decided to treat it as legacy behaviour and leave it there.
I guess we could just ... "fix" it and remove the test. Opinions?
When we were fixing the globbing code to work crossplat we found this behaviour where the slash of the fixed directory part was blindly prepended to the expanded wild card part. We decided to treat it as legacy behaviour and leave it there.
In this case I'm suggesting that the Content item be changed to
<Content Include="wwwroot\**" CopyToPublishDirectory="PreserveNewest" Exclude="$(DefaultItemExclude
As opposed to a core MSBuild change here.
In this case I'm suggesting that the Content item be changed
As far as I can remember, the slashes in the recursive directory part are the ones generated by Directory.GetDirectories
so depending on the OS they will either be back or forward slashes. This means that whatever slash orientation the user chooses for the fixed directory part, it will be inconsistent on either windows or !windows.
I am leaning towards just changing the user's slash to fit the rest. The alternative is to change the recursive slashes to fit the user's slashes, but that will likely cause it to crash on !windows where back-slash is a valid file character. (I remember an early .net core bug where nuget created a file called ~\.nuget\cache
, or something like that)
so depending on the OS they will either be back or forward slashes.
Ok I see. Maybe we should just leave things as they are then.
Team Triage: We think that it would be safe to normalize paths in this case where strings come from a glob expansion.
After creating an ASP.NET Core project I added a target to print out the Content items. After executing that target I get the following results.
The slashes here are not consistent. This is not a big deal because MSBuild will normalize these internally but if I have a custom task then the slashes not being consistent can cause issues I believe. I'd prefer these slashes to be consistent.
I think this is being caused by the globbing patterns for including wwwroot files.