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

Transform is previewed but not applied on publish #195

Open
francofs opened this issue Sep 9, 2016 · 11 comments
Open

Transform is previewed but not applied on publish #195

francofs opened this issue Sep 9, 2016 · 11 comments

Comments

@francofs
Copy link

francofs commented Sep 9, 2016

Hi,

I ran into an issue that has been bugging me for some time now, so I think maybe it is a bug.
I added transformation one the nuget packages of our project: NewRelic.Azure.WebSites.x64

It creates a configuration file in \newrelic\newrelic.config

Using the context menu, I add the transformations. (Dev, Hml, Prd).

The Transformation is on the Prd configuration (newrelic.Prd.config).

The original file:

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2008-2014 New Relic, Inc.  All rights reserved. -->
<!-- For more information see: https://newrelic.com/docs/dotnet/dotnet-agent-configuration -->
<configuration xmlns="urn:newrelic-config" agentEnabled="true">
  <service licenseKey="123456" ssl="true" />
  <application/>
  <log level="info" directory="c:\Home\LogFiles\NewRelic" />
  <transactionTracer enabled="true" transactionThreshold="apdex_f" stackTraceThreshold="500" recordSql="obfuscated" explainEnabled="true" explainThreshold="500" />
  <crossApplicationTracer enabled="true" />
  <errorCollector enabled="true">
    <ignoreErrors>
      <exception>System.IO.FileNotFoundException</exception>
      <exception>System.Threading.ThreadAbortException</exception>
    </ignoreErrors>
    <ignoreStatusCodes>
      <code>401</code>
      <code>404</code>
    </ignoreStatusCodes>
  </errorCollector>
  <browserMonitoring autoInstrument="true" />
  <threadProfiling>
    <ignoreMethod>System.Threading.WaitHandle:InternalWaitOne</ignoreMethod>
    <ignoreMethod>System.Threading.WaitHandle:WaitAny</ignoreMethod>
  </threadProfiling>
</configuration>

The transform file:

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform" xmlns="urn:newrelic-config" agentEnabled="true">
  <service licenseKey="987654" ssl="true" xdt:Transform="SetAttributes" />
</configuration>

If I preview the change, I see the transformation applied, however, when i publish it, the file is not transformed:

image

I have tried many things, including transforming not only the configuration transformation file as the publish profile transformation file. Neither worked. That's why I think I may have hit an unknown bug.

Below is the transformation preview:
image

Thank you for looking into it.

@iamkarlson
Copy link

The same problem

@davilimap
Copy link
Collaborator

@francofs Is the project repo available somewhere for me to verify the problem? If not, can you give specific steps to reproduce the issue starting from a new project?

@eat-sleep-code
Copy link

eat-sleep-code commented Mar 16, 2017

@davilimap Same issue here using:

  • Visual Studio 2017 15.0.0+26228.9 (this is the very latest version as of March 15, 2017, the same issue occurred on 26228.0)
  • SlowCheetah 2.5.48.45331
  • .NET Core 1.1 web application

Here is a fresh .NET Core web project. SlowCheetah is not working correctly in it. TestOfSlowCheetah.zip

1.) I get no Add Transform option in the menu. I have to manually create the file.
2.) Once I manually create the file, I can right-click on it and select Preview Transform and it previews just fine.
3.) On publish, the untransformed web.config gets copied

This kind of makes the extension pretty useless, so any help you can offer would be greatly appreciated.


PS: The module seems to work as expected on an older MVC5 ASP.NET Framework project. It just seems to be failing on the .NET Core project. If you are going to list that it works with VS 2017 you should be sure to include the major framework-variants.

@francofs
Copy link
Author

@davilimap I can't share the project repo, but it's easily reproduced:

1 - Create a new Web API Project in Visual Studio 2015 (SP3)
2 - Add a new configuration do the solution (besides Debug, Release) with any name,
3 - Through NuGet add NewRelic.Azure.WebSites.x64 package do de project. It will create a /newrelic folder
4 - Add the transforms to newrelic\newrelic.config
5 - Set the transformation file to the new configuration like the one in mu Original Post.
6 - Preview the transform to make sure it's ok.
7 - Publish the project (it can be to local file system, same effect)

You'll realize that the file is not transformed. You can try to transform other files in the root folder, like transforming an app.config and it will work. I think it may be related to the fact it's in a subfolder or something about its name. Not really sure.

Thanks for getting back to me.

@iamkarlson
Copy link

I'm not sure is it expected behaviour or not but eventually I found out what's happening here. My config is transformed (yes it is), but a transformed file is not placed under a project folder and is only in bin. What I did is put some post-build script to copy from my binaries back to the project. @davilimap have you ever considered an option to put the transformed config directly to the project folder instead of binaries?

@davilimap
Copy link
Collaborator

@iamkarlson This behavior has been considered previously, especially because of the how web.config works for debugging. Unfortunately, doing this can cause some problems for a lot of users as they might not be aware of the change to their project. Also, if the altered files are checked in, that might cause problems with version control.

@francofs Following your steps, I got to publishing the project and indeed it did not work as intended. Then, I realized that VS defaults your publish to use the Release configuration. When I went back to the publish settings, I switched the configuration to my created one (which I called Test). Can you try doing that to see if it works? I'm adding a pic below to show where I changed the configuration.

image

@eat-sleep-code
Copy link

@davilimap Does it work as expected for you in the TestOfSlowCheetah.zip I attached in my prior response?

@davilimap
Copy link
Collaborator

@eat-sleep-code Your case is a bit different for two reasons.
First, the current version of SlowCheetah purposefully ignores web.config files in all projects (the next version will ignore only for web projects) because transforms for that file are not handled by SlowCheetah. For more information on why this is, see #39. This is why the Add Transform option does not show up for web.config.
The second reason this does not work is that the publish pipeline for .NET Core projects is completely different than for previous projects, especially web. Even the way the web project is identified in .NET Core is different from older projects, which used an extra GUID to signal web apps. This means that the current version of SlowCheetah does not identify the project as web, but even if it did, it cannot insert itself into the publish process because of the differences in .NET Core.
I opened #235 to track this issue and put it in the backlog for now.

@francofs
Copy link
Author

francofs commented Mar 21, 2017 via email

@davilimap
Copy link
Collaborator

@francofs Yes, I successfully transformed the newrelic.config file using the same transformation as you showed in the beginning of the thread starting from the steps you provided to repro the issue from a new project but I am using VS2017. The only thing I did differently was to change the publish configuration to the one I created in step 2 (as shown in the picture in my previous message). Did you do this as well for the newly created project? If so, and it still doesn't publish correctly, then I will try switching over to VS2015 and seeing if the issue with its specific publish process.

@eat-sleep-code
Copy link

@davilimap thanks. It appears that MS short-sightedly dropped the web.config transform functionality on .net Core project because .net Core does not rely on web.config. That is all fine and great, but IIS does still rely on web.config so it wasn't very bright for them to drop support. So my particular issue doesn't appear to be related to slow-cheetah at all.

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

4 participants