Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SlowCheetah does not transform when project is net48 Microsoft.NET.Sdk.Worker #254

Open
ristogod opened this issue May 10, 2022 · 1 comment

Comments

@ristogod
Copy link

I have a code base that I build in both net48 and net6.0 and various executable projects that run either version. I have net48 dependency I cannot free myself from. However, the code works fine when targeting either framework.

For some of the projects, they are command-line driven console apps and the below works fine. I get an MyProject.exe.config file that is both transformed as well as includes all binding redirects.

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

   <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>net48</TargetFramework>
   </PropertyGroup>

   <ItemGroup>
      <PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="4.0.8">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      </PackageReference>
   </ItemGroup>

   <ItemGroup>
      <None Update="App.config">
         <CopyToOutputDirectory>Never</CopyToOutputDirectory>
         <TransformOnBuild>true</TransformOnBuild>
      </None>
      <None Update="App.Debug.config">
         <DependentUpon>App.config</DependentUpon>
        <IsTransformFile>true</IsTransformFile>
      </None>
      <None Update="App.Release.config">
         <DependentUpon>App.config</DependentUpon>
         <IsTransformFile>true</IsTransformFile>
      </None>
   </ItemGroup>

</Project>

However, I also need some functionality in a Windows Service, and so I have made a project file like this, and it simply does not do the transforms at all.

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

   <PropertyGroup>
      <OutputType>Exe</OutputType>
      <TargetFramework>net48</TargetFramework>
   </PropertyGroup>

   <ItemGroup>
      <PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="4.0.8">
        <PrivateAssets>all</PrivateAssets>
        <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      </PackageReference>
   </ItemGroup>

   <ItemGroup>
      <None Update="App.config">
         <CopyToOutputDirectory>Never</CopyToOutputDirectory>
         <TransformOnBuild>true</TransformOnBuild>
      </None>
      <None Update="App.Debug.config">
         <DependentUpon>App.config</DependentUpon>
        <IsTransformFile>true</IsTransformFile>
      </None>
      <None Update="App.Release.config">
         <DependentUpon>App.config</DependentUpon>
         <IsTransformFile>true</IsTransformFile>
      </None>
   </ItemGroup>

</Project>

I've tried using Microsoft.DotNet.Xdt.Tools.2.0.0 instead of Microsoft.VisualStudio.SlowCheetah.4.0.8, but I can't seem to get it to produce a MyProject.exe.config file that both transforms as well as generates all the BindingRedirects correctly.

@RussEbbing
Copy link

I'm having the same issue but with .net 7.0. Same configurations as above but for AppSettings.json. Right context menu "Preview Transformation" works correctly however when building or publishing the AppSettings.json emitted has not been transformed.

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

  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
    <Configurations>Debug;Release;Dev;Prod</Configurations>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <OutputType>exe</OutputType>
    <Nullable>enable</Nullable>
    <PublishSingleFile Condition="'$(Configuration)' == 'Release'">true</PublishSingleFile>
    <PublishSingleFile Condition="'$(Configuration)'=='Prod'">true</PublishSingleFile>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <PlatformTarget>AnyCPU</PlatformTarget>
  </PropertyGroup>

   <ItemGroup>
    <PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="4.0.8">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <None Update="AppSettings.json">
      <TransformOnBuild>true</TransformOnBuild>
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </None>
    <None Update="AppSettings.Debug.json">
      <IsTransformFile>true</IsTransformFile>
      <DependentUpon>AppSettings.json</DependentUpon>
    </None>
    <None Update="AppSettings.Dev.json">
      <IsTransformFile>true</IsTransformFile>
      <DependentUpon>AppSettings.json</DependentUpon>
    </None>
    <None Update="AppSettings.DevPublish.json">
      <IsTransformFile>true</IsTransformFile>
      <DependentUpon>AppSettings.json</DependentUpon>
    </None>
    <None Update="AppSettings.Prod.json">
      <IsTransformFile>true</IsTransformFile>
      <DependentUpon>AppSettings.json</DependentUpon>
    </None>
    <None Update="AppSettings.ProdPublish.json">
      <IsTransformFile>true</IsTransformFile>
      <DependentUpon>AppSettings.json</DependentUpon>
    </None>
    <None Update="AppSettings.Release.json">
      <IsTransformFile>true</IsTransformFile>
      <DependentUpon>AppSettings.json</DependentUpon>
    </None>
  </ItemGroup>

</Project>

ttstanley pushed a commit that referenced this issue Nov 14, 2024
Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.5.6 to 2.5.7.
- [Release notes](https://github.com/xunit/visualstudio.xunit/releases)
- [Commits](xunit/visualstudio.xunit@2.5.6...2.5.7)

---
updated-dependencies:
- dependency-name: xunit.runner.visualstudio
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants