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

Linked files run transform from original file location instead of linked location #250

Open
jklawrence opened this issue Jan 20, 2022 · 0 comments

Comments

@jklawrence
Copy link

Given a folder structure like:

Foo/
├─ Foo.csproj
├─ Web.config
Bar/
├─ Bar.csproj
├─ Web.Debug.config

And with Bar.csproj including ../Foo/Web.config as a linked file, Slow Cheetah does not apply transforms from Bar's Web.Debug.config file.

Here's Bar.csproj:

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

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <OutputType>Library</OutputType>
  </PropertyGroup>

  <ItemGroup>
    <None Include="..\Foo\Web.config">
      <Link>Web.config</Link>
      <TransformOnBuild>true</TransformOnBuild>
    </None>
    <None Update="Web.Debug.config">
      <IsTransformFile>True</IsTransformFile>
      <DependentUpon>Web.config</DependentUpon>
    </None>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Bar\Bar.csproj" />
  </ItemGroup>

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

</Project>

When running MSBuild with diagnostic verbosity, I can see that it's looking for the TransformFile in the Foo folder instead of Bar:

Added Item(s): 
    _ScNoneFilesToTransform=
        ..\Foo\Web.config
                CopyToOutputDirectory=PreserveNewest
                DestinationFile=obj\Debug\net472\Web.config
                Link=Web.config
                OriginalItemSpec=..\Foo\Web.config
                SourceFile=c:\SomePath\Foo\Web.config
                Subtype=Designer
                TargetPath=Web.config
                TransformFile=..\Foo\Web.Debug.config
                TransformOnBuild=true
                _BuildAction=None

I've worked around this for now by adding a custom target that runs after ScCollectTransformFiles:

  <Target Name="FixSlowCheetahTransformFile" AfterTargets="ScCollectTransformFiles">
    <ItemGroup>
      <ScFilesToTransform Update="..\Foo\Web.config">
        <TransformFile>Web.$(Configuration).config</TransformFile>
      </ScFilesToTransform>
    </ItemGroup>
  </Target>

Is there a supported way to run transforms using the linked file location?

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

1 participant