Почему мой проект собирается с перерывами? - PullRequest
0 голосов
/ 19 апреля 2020

Я ожидаю, что мой проект будет создаваться каждый раз, когда я делаю dotnet build или dotnet run, но это не так. Я получаю ошибки MSB4018.

Мой проект построен так, что мой клиент отделен от того, что совместно используется клиентом, редактором и сервером. Когда я собираю сервер, все работает нормально, я никогда не получаю сообщение об ошибке. Однако, когда я собираю клиента, который определяет константы WEBGL и CLIENT, я получаю ошибки.

Особенность заключается в том, что если я комментирую часть моего общего файла csproj с условным выводом, попробуйте build или run, затем вставьте его обратно и build или run, он отлично работает.

Здесь shared.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>

  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MessagePack" Version="2.1.115" />
    <PackageReference Include="LZMA-SDK" Version="19.0.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\libs\Audrey\Audrey\Audrey.csproj" />
    <ProjectReference Include="..\libs\JanusLiteNetLib\Janus\Janus.csproj" />
    <ProjectReference Include="..\libs\eeNet\EventEmitter\EventEmitter.csproj" />
  </ItemGroup>

  <!-- This is what I need to comment out -->
  <ItemGroup Condition="'$(DefineConstants)' == 'WEBGL;CLIENT' " >
    <PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview2.20160.5" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
  </ItemGroup>

  <ItemGroup Condition="'$(DefineConstants)' == 'WEBGL;CLIENT' " >
    <ProjectReference Include="..\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj" />
  </ItemGroup>
  <!-- end of what I need to comment out -->

</Project>

Это клиентский csproj :

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <RazorLangVersion>3.0</RazorLangVersion>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Fluent.IL" Version="1.0.0-alpha9" />
    <PackageReference Include="Jint" Version="2.11.58" />
    <PackageReference Include="LZMA-SDK" Version="19.0.0" />
    <PackageReference Include="MessagePack" Version="2.1.115" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor.HttpClient" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview8.19405.7" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="3.2.0-preview2.20160.5" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Build" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="3.2.0-preview2.20160.5" PrivateAssets="all" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj" />
    <ProjectReference Include="..\libs\Audrey\Audrey\Audrey.csproj" />
    <ProjectReference Include="..\libs\JanusLiteNetLib\Janus\Janus.csproj" />
    <ProjectReference Include="..\libs\eeNet\EventEmitter\EventEmitter.csproj" />
    <ProjectReference Include="..\shared\shared.csproj">
      <Properties>DefineConstants=WEBGL;CLIENT</Properties>
    </ProjectReference>

  </ItemGroup>

</Project>

Я также пытался выполнить следующее условие:

  <ItemGroup Condition="$(DefineConstants.Contains('WEBGL'))" >

, а также:

  <ItemGroup Condition="$(DefineConstants.Contains('WEBGL')) == 'true'" >

. Задавая этот вопрос, он фактически дважды работал в грести, когда я попробовал последнее условие. Но не в третий раз.

Вот ошибка:

C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018: The "SourceLink.Create.CommandLine.CreateTask" task failed unexpectedly. [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018: System.IO.IOException: The process cannot access the file 'D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\obj\Debug\netstandard2.0\sourcelink.json' because it is being used by another process. [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018:    at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle) [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018:    at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options) [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018:    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018:    at System.IO.File.Open(String path, FileMode mode, FileAccess access, FileShare share) [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018:    at SourceLink.Create.FileUtil.OpenWrite(String file) in C:\projects\sourcelink\SourceLink.Create.Shared\FileUtil.cs:line 8 [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018:    at SourceLink.Create.CommandLine.CreateTask.Execute() in C:\projects\sourcelink\SourceLink.Create.CommandLine\CreateTask.cs:line 53 [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
C:\Users\Administrator\.nuget\packages\sourcelink.create.commandline\2.8.3\build\SourceLink.Create.CommandLine.targets(30,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [D:\Dev\LoW\legend-of-worlds-cs\libs\Canvas\src\Blazor.Extensions.Canvas\Blazor.Extensions.Canvas.csproj]
...