Skip to content

Commit

Permalink
Workaround O# path bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pranavkm committed Mar 19, 2021
1 parent 0ce2485 commit 1d373dc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public async ValueTask<bool> TryHandleFileChange(DotNetWatchContext context, Fil

Solution? updatedSolution = null;
ProjectId updatedProjectId;
if (_currentSolution.Projects.SelectMany(p => p.Documents).FirstOrDefault(d => d.FilePath == file.FilePath) is Document documentToUpdate)
if (_currentSolution.Projects.SelectMany(p => p.Documents).FirstOrDefault(d => string.Equals(d.FilePath, file.FilePath, StringComparison.OrdinalIgnoreCase)) is Document documentToUpdate)
{
var sourceText = await GetSourceTextAsync(file.FilePath);
updatedSolution = documentToUpdate.WithText(sourceText).Project.Solution;
updatedProjectId = documentToUpdate.Project.Id;
}
else if (_currentSolution.Projects.SelectMany(p => p.AdditionalDocuments).FirstOrDefault(d => d.FilePath == file.FilePath) is AdditionalDocument additionalDocument)
else if (_currentSolution.Projects.SelectMany(p => p.AdditionalDocuments).FirstOrDefault(d => string.Equals(d.FilePath, file.FilePath, StringComparison.OrdinalIgnoreCase)) is AdditionalDocument additionalDocument)
{
var sourceText = await GetSourceTextAsync(file.FilePath);
updatedSolution = _currentSolution.WithAdditionalDocumentText(additionalDocument.Id, sourceText, PreservationMode.PreserveValue);
Expand Down
15 changes: 15 additions & 0 deletions src/RazorSdk/Razor.slnf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"solution": {
"path": "..\\..\\sdk.sln",
"projects": [
"src\\BuiltInTools\\AspNetCoreDeltaApplier\\Microsoft.Extensions.AspNetCoreDeltaApplier.csproj",
"src\\RazorSdk\\SourceGenerators\\Microsoft.NET.Sdk.Razor.SourceGenerators.csproj",
"src\\RazorSdk\\Tasks\\Microsoft.NET.Sdk.Razor.Tasks.csproj",
"src\\RazorSdk\\Tool\\Microsoft.NET.Sdk.Razor.Tool.csproj",
"src\\Resolvers\\Microsoft.DotNet.NativeWrapper\\Microsoft.DotNet.NativeWrapper.csproj",
"src\\Tests\\Microsoft.NET.Sdk.Razor.Tests\\Microsoft.NET.Sdk.Razor.Tests.csproj",
"src\\Tests\\Microsoft.NET.Sdk.Razor.Tool.Tests\\Microsoft.NET.Sdk.Razor.Tool.Tests.csproj",
"src\\Tests\\Microsoft.NET.TestFramework\\Microsoft.NET.TestFramework.csproj"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ Copyright (c) .NET Foundation. All rights reserved.
<_RazorAdditionalFile Include="@(RazorComponentWithTargetPath)" />
<!-- Ignore .cshtml files if RazorCompileOnBuild=false -->
<_RazorAdditionalFile Include="@(RazorGenerateWithTargetPath)" Condition="'$(RazorCompileOnBuild)' != 'false'" />

<!-- Workaround for O# bug where it modifies the root path on Windows-->
<_RazorOmnisharpWorkAround Include="$([System.String]::Copy(%(_RazorAdditionalFile.RootDir)).ToLower())%(Directory)%(FileName)%(Extension)"
TargetPath="%(_RazorAdditionalFile.TargetPath)"
GeneratedOutputFullPath="%(_RazorAdditionalFile.GeneratedOutputFullPath)"
CssScope="%(_RazorAdditionalFile.CssScope)"
Condition="$([MSBuild]::IsOSPlatform(`Windows`))" />

<_RazorAdditionalFile Remove="@(_RazorAdditionalFile)" Condition="$([MSBuild]::IsOSPlatform(`Windows`))" />
<_RazorAdditionalFile Include="@(_RazorOmnisharpWorkAround)" Condition="$([MSBuild]::IsOSPlatform(`Windows`))" />

<AdditionalFiles Include="@(_RazorAdditionalFile)" />

<!-- pre-emptively include the files generated by source-generators -->
Expand Down

0 comments on commit 1d373dc

Please sign in to comment.