File: dotnet-watch.csproj
Web Access
Project: ..\..\..\src\BuiltInTools\dotnet-watch\dotnet-watch.csproj (dotnet-watch)
<Project Sdk="Microsoft.NET.Sdk">
 
  <Import Project="..\AspireService\Microsoft.WebTools.AspireService.projitems" Label="Shared" />
  <Import Project="..\HotReloadAgent.PipeRpc\Microsoft.DotNet.HotReload.Agent.PipeRpc.projitems" Label="Shared" />
  <Import Project="..\HotReloadAgent.Data\Microsoft.DotNet.HotReload.Agent.Data.projitems" Label="Shared" />
  <Import Project="..\HotReloadClient\Microsoft.DotNet.HotReload.Client.projitems" Label="Shared" />
 
  <PropertyGroup>
    <TargetFramework>$(SdkTargetFramework)</TargetFramework>
    <OutputType>exe</OutputType>
    <Description>Command line tool to watch for source file changes during development and restart the dotnet command.</Description>
    <RootNamespace>Microsoft.DotNet.Watch</RootNamespace>
    <StrongNameKeyId>MicrosoftAspNetCore</StrongNameKeyId>
    <UseAppHost>false</UseAppHost>
    <RuntimeIdentifier />
 
    <!-- Avoid https://github.com/dotnet/arcade/issues/9305 -->
    <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
 
    <!--
      Disable CS9057 in source-only dev/ci builds. This is necessary because dotnet-watch distributes some ASP.NET Core
      analyzers. These analyzers get built with a dependency on the live version of Microsoft.CodeAnalysis. In a dev/ci
      build, the assembly version associated with Microsoft.CodeAnalysis in that case is 42.42.42.4242, set by Arcade in
      dev/ci builds. So when building dotnet-watch with its analyzer dependencies, it will cause CS9057 because the 
      analyzer assembly version is not the same as the compiler assembly version being used by the sdk that the project
      is being built with. But this is fine because the analyzer is just being used here to distribute it with the tool.
    -->
    <NoWarn Condition="'$(DotNetBuildSourceOnly)' == 'true' and '$(OfficialBuild)' != 'true'">$(NoWarn);CS9057</NoWarn>
  </PropertyGroup>
 
  <ItemGroup>
    <EmbeddedResource Update="**\*.resx" GenerateSource="true" />
    <Content Include="Watch\DotNetWatch.targets" TargetPath="DotNetWatch.targets" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
  </ItemGroup>
 
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="System.CommandLine" />
    <PackageReference Include="Microsoft.Build" ExcludeAssets="runtime" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Build.Framework" ExcludeAssets="runtime" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Build.Tasks.Core" ExcludeAssets="runtime" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Build.Utilities.Core" ExcludeAssets="runtime" PrivateAssets="All" />
    <PackageReference Include="Microsoft.Build.Locator" />
    <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" />
    <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" />
    <PackageReference Include="Microsoft.NET.StringTools" ExcludeAssets="runtime" PrivateAssets="All" />
 
    <Compile Include="$(RepoRoot)src\Common\PathUtilities.cs" LinkBase="Common" />
  </ItemGroup>
 
  <ItemGroup>
    <ProjectReference Include="$(RepoRoot)\src\Cli\dotnet\dotnet.csproj" />
 
    <ProjectReference Include="..\DotNetWatchTasks\DotNetWatchTasks.csproj">
      <PrivateAssets>all</PrivateAssets>
      <OutputItemType>Content</OutputItemType>
      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <UndefineProperties>TargetFramework;TargetFrameworks</UndefineProperties>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </ProjectReference>
 
    <ProjectReference Include="..\BrowserRefresh\Microsoft.AspNetCore.Watch.BrowserRefresh.csproj">
      <PrivateAssets>all</PrivateAssets>
      <OutputItemType>Content</OutputItemType>
      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <UndefineProperties>TargetFramework;TargetFrameworks</UndefineProperties>
      <TargetPath>hotreload\net6.0\Microsoft.AspNetCore.Watch.BrowserRefresh.dll</TargetPath>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </ProjectReference>
 
    <ProjectReference Include="..\DotNetDeltaApplier\Microsoft.Extensions.DotNetDeltaApplier.csproj">
      <PrivateAssets>all</PrivateAssets>
      <OutputItemType>Content</OutputItemType>
      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <SetTargetFramework>TargetFramework=net10.0</SetTargetFramework>
      <TargetPath>hotreload\net10.0\Microsoft.Extensions.DotNetDeltaApplier.dll</TargetPath>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
    </ProjectReference>
 
    <ProjectReference Include="..\DotNetDeltaApplier\Microsoft.Extensions.DotNetDeltaApplier.csproj">
      <PrivateAssets>all</PrivateAssets>
      <OutputItemType>Content</OutputItemType>
      <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
      <SetTargetFramework>TargetFramework=net6.0</SetTargetFramework>
      <TargetPath>hotreload\net6.0\Microsoft.Extensions.DotNetDeltaApplier.dll</TargetPath>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </ProjectReference>
  </ItemGroup>
 
  <!-- Publish dotnet-watch files to the redist testhost folder so that in innerloop, redist doesn't need to be built again. -->
  <Target Name="PublishDotnetWatchToTestHost" BeforeTargets="AfterBuild">
    <ItemGroup>
      <!--
        To reduce the size of the SDK, we use the compiler dependencies that are located in the `Roslyn/bincore` location
        instead of shipping our own copies in the dotnet-watch tool. These assemblies will be resolved by path in the
        dotnet-watch executable.
 
        We make an exception for the Microsoft.CodeAnalysis binaries deployed with the MSBuildWorkspace BuildHosts, since those don't
        have any logic to pick up Roslyn from another location. Those can be addressed a different way which tracked in
        https://github.com/dotnet/roslyn/issues/70945.
 
        Keep excluded files in sync with the list in GenerateLayout.targets.
      -->
      <_DotnetWatchInputFile Include="$(TargetDir)**"
                             Condition="('%(Filename)' != 'Microsoft.CodeAnalysis' and
                                         '%(Filename)' != 'Microsoft.CodeAnalysis.resources' and
                                         '%(Filename)' != 'Microsoft.CodeAnalysis.CSharp' and
                                         '%(Filename)' != 'Microsoft.CodeAnalysis.CSharp.resources') or
                                        $([MSBuild]::ValueOrDefault('%(FullPath)', '').Contains('BuildHost'))" />
    </ItemGroup>
 
    <Copy SourceFiles="@(_DotnetWatchInputFile)" DestinationFiles="@(_DotnetWatchInputFile->'$(TestHostDotNetRoot)sdk\$(Version)\DotnetTools\dotnet-watch\$(Version)\tools\$(SdkTargetFramework)\any\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true">
      <Output TaskParameter="CopiedFiles" ItemName="FileWrites" />
    </Copy>
  </Target>
 
</Project>