slow-cheetah
slow-cheetah copied to clipboard
[3.1.66] Transform always copies source to ouput even if not marked as such
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
- originalSerilog.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?
I was able to work around it adding these items:
<ItemGroup>
<WebPublishExtnsionsToExcludeItem Include=".json" />
<WebPublishExtnsionsToExcludeItem Include=".xml" />
</ItemGroup>
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.
Just noticed this looks like a duplicate of #154 ?
Actually I don't think it's a duplicate as #154 points at a .NET Core target.
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.
Fixed by #169
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:
Reverted. Needs to be analyzed better and added in a future major update
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 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 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 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.