slow-cheetah icon indicating copy to clipboard operation
slow-cheetah copied to clipboard

[3.1.66] Transform always copies source to ouput even if not marked as such

Open paulomorgado opened this issue 5 years ago • 12 comments

I have some configuration files on a System.Web MVC Web API project.

On my csproj I have items like this:

<Content Include="Web.config">
  <SubType>Designer</SubType>
</Content>
<None Include="Web.Debug.config">
  <DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.LocalDebug.config">
  <DependentUpon>Web.config</DependentUpon>
  <SubType>Designer</SubType>
</None>
<None Include="Web.LocalRelease.config">
  <DependentUpon>Web.config</DependentUpon>
  <TransformOnBuild>true</TransformOnBuild>
</None>
<None Include="Web.Release.config">
  <DependentUpon>Web.config</DependentUpon>
</None>
<Content Include="Serilog.config.json">
  <TransformOnBuild>true</TransformOnBuild>
</Content>
<None Include="Serilog.config.Debug.json">
  <DependentUpon>Serilog.config.json</DependentUpon>
  <IsTransformFile>True</IsTransformFile>
</None>
<None Include="Serilog.config.LocalDebug.json">
  <DependentUpon>Serilog.config.json</DependentUpon>
  <IsTransformFile>True</IsTransformFile>
</None>
<None Include="Serilog.config.LocalRelease.json">
  <DependentUpon>Serilog.config.json</DependentUpon>
  <IsTransformFile>True</IsTransformFile>
</None>
<None Include="Serilog.config.Release.json">
  <DependentUpon>Serilog.config.json</DependentUpon>
  <IsTransformFile>True</IsTransformFile>
</None>

However, the source files are copied to the bin folder, unlike what happens with the web.config.

After the build, I end up with:

  • root
    • web.config - result of transformations
    • Serilog.config.json - result of transformations
    • bin
      • Serilog.config.json - original Serilog.config.json

LocalRelease and LocalDebug are web publish profiles.

I suspect this is due to https://github.com/Microsoft/slow-cheetah/blob/master/src/Microsoft.VisualStudio.SlowCheetah/Build/Microsoft.VisualStudio.SlowCheetah.targets#L92

How can I prevent the source files from being sent to bin?

paulomorgado avatar Nov 08 '18 17:11 paulomorgado

I was able to work around it adding these items:

<ItemGroup>
  <WebPublishExtnsionsToExcludeItem Include=".json" />
  <WebPublishExtnsionsToExcludeItem Include=".xml" />
</ItemGroup>

paulomorgado avatar Nov 08 '18 17:11 paulomorgado

We're also seeing this and it took us a few hours to figure this out.. Not comfortable with the work around as it could include things we do want to publish.

ShaneCourtrille avatar Nov 21 '18 19:11 ShaneCourtrille

Just noticed this looks like a duplicate of #154 ?

ShaneCourtrille avatar Nov 21 '18 19:11 ShaneCourtrille

Actually I don't think it's a duplicate as #154 points at a .NET Core target.

ShaneCourtrille avatar Nov 21 '18 19:11 ShaneCourtrille

I was taking some slow dev time to clean up our build/deploy process and noticed these transformed files being included under the bin\ folder.

@paulomorgado nailed it though. The problem is that line of code on https://github.com/Microsoft/slow-cheetah/blob/master/src/Microsoft.VisualStudio.SlowCheetah/Build/Microsoft.VisualStudio.SlowCheetah.targets#L92

I think it should be... <CopyToOutputDirectory Condition=" '$(CopyToOutputDirectory)' != '' ">$(CopyToOutputDirectory)</CopyToOutputDirectory>. I'll see if I can figure out how to create a PR for this.

chrispauly avatar Nov 29 '18 15:11 chrispauly

Fixed by #169

davilimap avatar Jan 10 '19 18:01 davilimap

Ok, the code changes for #166 and #169 have completely broken SlowCheetah and need to be removed. It doesn't even work by following the documentation exactly as written. This is the biggest screw-up that I've ever seen. HOW WAS THIS RELEASED WITHOUT ANY REGRESSION TESTING?

Here is a link to the documentation which no longer works:

Transforming Files with SlowCheetah

Kaelum avatar Mar 27 '19 17:03 Kaelum

Reverted. Needs to be analyzed better and added in a future major update

davilimap avatar Sep 18 '19 21:09 davilimap

Any idea when this will be addressed? Not completely sure of why it does it, but I guess it can't be a simple setting to just not do it?

angelicochris avatar Mar 09 '20 13:03 angelicochris

@angelicochris there really isn't anything to address. The OP is asking for new functionality, as the documentation specifically states that ASP.NET Web Applications are not supported. The addon itself is functioning exactly as it is supposed to be. The entire purpose of this addon is to transform the files and send them to the output folder(s). It works very well with ASP.NET Core Web Applications, as they are actually Console Applications.

While it doesn't support ASP.NET Framework Web Applications (which is mainly due to his reason), you can use it. If you don't want the files in the ~/bin folder, either delete them during the Post Build event, or during Publish. There are several MSBuild options available as well, you just need to research them.

Kaelum avatar Mar 10 '20 07:03 Kaelum

@Kaelum I am not to familiar with ASP.NET Core Web Applications, so I'm curious, what is the purpose of putting the original config files in the bin folder?

angelicochris avatar Mar 10 '20 14:03 angelicochris

@angelicochris ASP.NET Core doesn't place the "non-transformed" configuration file into the ~/bin folder. It does place the transformed configuration file into the ~/bin folder, as it is supposed to.

ASP.NET Core uses a completely different folder structure. The ~/bin folder is not inside of the content folder, instead the ~/bin, ~/Views, and ~/wwwroot (the static file folder) folders are all siblings, sitting at the same level by default. The root folders can actually be moved anywhere, as long as you update the reference pointer.

Transforms inside of the ~/Views and ~/wwwroot folders, stay in those folders. Any transforms outside of those folders, are considered code folders, and they will be placed in the ~/bin folder when configured to do so. I believe that Web Pages works in the same way, but I haven't used it yet.

Kaelum avatar Mar 10 '20 18:03 Kaelum