Is it possible to use the web.config transformations for app.config files within a VSTS release template? - azure-pipelines-release-pipeline

I'm aware that you can use web.config transformations as part of the build for app.config files, but in my case, I'm trying to do this for a little scheduled task that gets deployed to an on-premise server for multiple environments.
I'd rather not have to create multiple build configurations given the only change is the app.config, so I'm trying to use the Magic Chunks extension, but due to the size of the changes I want to make, I'm having to use a json file (rather than using inline json).
When I look at the release logs, the Magic Chunks step is failing with:
2018-01-10T17:33:27.6366230Z ##[section]Starting: Config transform - \\tfs-build\Tasks\DevAzureDeliveryDaemonTest\AzureDispatchers.xml
2018-01-10T17:33:27.6366230Z ==============================================================================
2018-01-10T17:33:27.6366230Z Task : Config transformation
2018-01-10T17:33:27.6366230Z Description : Transform config file with Magic Chunks
2018-01-10T17:33:27.6366230Z Version : 2.0.3
2018-01-10T17:33:27.6366230Z Author : Sergey Zwezdin
2018-01-10T17:33:27.6366230Z Help : [More Information](https://github.com/sergeyzwezdin/magic-chunks)
2018-01-10T17:33:27.6366230Z ==============================================================================
2018-01-10T17:33:27.6522335Z Preparing task execution handler.
2018-01-10T17:33:27.8710415Z Executing the powershell script: C:\agent\_work\_tasks\MagicChunks_985284e0-a7d2-4e4d-802c-0a516bffaadf\2.0.3\transform.ps1
2018-01-10T17:33:28.4335027Z ##[error]System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
2018-01-10T17:33:28.4335027Z at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
2018-01-10T17:33:28.4335027Z at System.Reflection.Assembly.GetTypes()
2018-01-10T17:33:28.4335027Z at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes)
2018-01-10T17:33:28.4335027Z at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing()
2018-01-10T17:33:28.4335027Z at System.Management.Automation.CommandProcessorBase.Complete()
2018-01-10T17:33:28.4960072Z Transformation found: dispatcher[#Name='oldvalue']/#Name: newvalue
(The other transformations defined in the json file are found here, but redacted for brevity)
2018-01-10T17:33:28.4960072Z
2018-01-10T17:33:28.4960072Z
2018-01-10T17:33:28.5741199Z ##[error]System.Management.Automation.MethodInvocationException: Exception calling "Transform" with "4" argument(s): "Could not load file or assembly 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified." ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2018-01-10T17:33:28.5741199Z at MagicChunks.TransformTask.Transform(String type, String sourcePath, String targetPath, TransformationCollection transformation)
2018-01-10T17:33:28.5741199Z at CallSite.Target(Closure , CallSite , Type , Object , Object , Object , Object )
2018-01-10T17:33:28.5741199Z --- End of inner exception stack trace ---
2018-01-10T17:33:28.5741199Z at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
2018-01-10T17:33:28.5741199Z at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame)
2018-01-10T17:33:28.5741199Z at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2018-01-10T17:33:28.5741199Z at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2018-01-10T17:33:28.5741199Z ##[error]PowerShell script completed with 2 errors.
2018-01-10T17:33:28.5897571Z ##[section]Finishing: Config transform - \\tfs-build\Tasks\DevAzureDeliveryDaemonTest\AzureDispatchers.xml
Has anyone seen this before, and know how to resolve (or know of a better way to achieve this)?

This appears to be an issue with version 2.x of the Magic Chunks Task. Until that is resolved, changing the release to use version 1.x of the task allows to complete

Related

"Error Deserializing JSON Credential Data" gcp auth file c#

Following on from this question, I'd like to open a related one to verify an answer.
Originally my code looked like
string path2key = "C:/Users/me/Downloads/project-id-1-letters.json";
string jsonString = File.ReadAllText(path2key);
Console.WriteLine(jsonString); // this works and prints correctly
// I presume I'm passing json as a string???
var credential = GoogleCredential.FromJson(jsonString);
but I was getting the following error
System.InvalidOperationException: 'Error deserializing JSON credential data.'
FileNotFoundException: Could not load file or assembly 'System.Security.Permissions, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
I'm using netframework 4.5, meaning I'm somewhat limited in updating packages to the latest and greatest.
The other answer is correct. I was about to post the same answer but #serge beat me to it.
The class GoogleCredentials has a member FromJson. That member takes a string argument. In your code, you were trying to pass an object.
For the error in your comment to the answer:
FileNotFoundException: Could not load file or assembly 'System.Security.Permissions
That error can be corrected by using nuget package manager and adding System.Security.Permissions or via the CLI:
dotnet add package System.Security.Permissions

Why does DriverManager.getConnection() lookup fail in GroovyConsole?

The following Groovy script works correctly from the command line. (I successfully get a Connection.)
// ---- jdbc_test.groovy
import java.sql.*
Class.forName("com.mysql.jdbc.Driver")
def con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test",
"root",
"password")
println con
> groovy -cp lib\mysql-connector-java-5.1.25-bin.jar script\jdbc_test.groovy
com.mysql.jdbc.JDBC4Connection#6025e1b6
But if the same script is loaded into GroovyConsole (2.4.3) and run - after adding the mysql-connector-java-5.1.25-bin.jar using 'Script' | 'Add Jar(s) to ClassPath' - it fails:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
at java_sql_DriverManager$getConnection.call(Unknown Source)
at jdbc_test.run(jdbc_test.groovy:3)
Every other package or class I have added to the classpath in GroovyConsole and experimented with has worked. Is there some unexpected interaction of Groovy's class loading and the way DriverManager works?
Is there a way around this? I'm trying to use the GroovyConsole to interactively test out some JDBC code (a library of functions, each of which takes a Connection as its first argument).
UPDATE: The Class.forName() part appears to be working fine. If I 'Script' | 'Clear Script Context' and rerun the script in GroovyConsole, I instead get:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
If I add mysql-connector-java-5.1.25-bin.jar back in, I go back to getting:
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/test
Solution: The driver has to be on the classpath.
Reason:
If you look into the DriverManager class you find code like this: Class.forName(driver.getClass().getName(), true, classLoader);. This is to check if the driver is accessible from your classloader context. And that context is determined by going back to the class that is calling he DriverManager. This code is written for Java, thus assumes a certain amount of frames on the call stack to go back. Since Groovy does not do direct calls (unless you use #CompileStatic) this number is wrong and leads usually to a Groovy core class to be selected, resulting in Groovy main loader to be selected.... in the past this was often even the JDK system classloader because of reflection. So even though the driver is loaded and registered, it is not accessible to you.
Note: with jdbc4 the driver should register itself, just by being on the classpath

Receiving "bad symbolic reference to org.json4s.JsonAST..." in Eclipse Scala-IDE using 2.11

I am attempting to use the Eclipse Scala-IDE for 2.11 (downloaded the prepackaged bundle from the web-site). I have been using the Scala Worksheet to work with a SaaS API returning JSON. I've been pushing through just using String methods. I decided to begin using json4s. I went to http://mvnrepository.com/ and obtained the following libraries:
json4s-core-2.11-3.2.10.jar
json4s-native-2.11-3.2.10.jar
paranamer-2.6.jar
I have added all three jars to the Project's Build Path. And they appear under the project's "Referenced Libraries".
I have the following code in a Scala Worksheet:
package org.public_domain
import org.json4s._
import org.json4s.native.JsonMethods._
object WorkSheet6 {
println("Welcome to the Scala worksheet")
parse(""" { "numbers" : [1, 2, 3, 4] } """)
println("Bye")
}
I am receiving the following two compilation errors:
bad symbolic reference to org.json4s.JsonAST.JValue encountered in class file 'package.class'. Cannot access type JValue in value org.json4s.JsonAST. The current classpath may be missing a definition for org.json4s.JsonAST.JValue, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.
bad symbolic reference to org.json4s.JsonAST.JValue encountered in class file 'package.class'. Cannot access type JValue in value org.json4s.JsonAST. The current classpath may be missing a definition for org.json4s.JsonAST.JValue, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.
When I go look in the org.json4s package in the json4s-core-2.11-3.2.10.jar file, there is in fact no .class file indicating any sort of compiled object JsonAST.
This is a showstopper. Any help on this would be greatly appreciated.
Your classpath is incomplete. You are missing a dependency of json4s-core.
bad symbolic reference to org.json4s.JsonAST.JValue encountered in class file 'package.class'. Cannot access type JValue in value org.json4s.JsonAST. The current classpath may be missing a definition for org.json4s.JsonAST.JValue, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.
The simplest way to consume Scala or Java libraries is to use sbt or maven. They bring in (transitive) dependencies for you. If you check the pom definition of json4s-core library, you notice it depends on json4s-ast. You should add that jar to your build path as well.

Object of type 'manifest' and path 'C:\CustomManifest.xml' cannot be created

I am struggling with msdeploy (aka Web Deploy). I have tried to create a simple manifest (from the example of MSDN) :
<sitemanifest>
<appHostConfig path="mySite" />
</sitemanifest>
Unfortunately, any command with this manifest as a source dies with the following message :
msdeploy -verb:dump -source:manifest=c:\CustomManifest.xml
Error: Object of type 'manifest' and path 'C:\CustomManifest.xml' cannot be created.
Error: One or more entries in the manifest 'sitemanifest' are not valid.
Error Code: ERROR_SITE_DOES_NOT_EXIST
More Information: Site 'mySite' does not exist. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_SITE_DOES_NOT_EXIST.
Error count: 1.
Any Idea ?
OK, finally understood my issue : a manifest is made only to export what you need. It is not made to generate something from scratch. To generate a web site, the package provider has to be used.

installing an Ocaml hump library on mutualized server

I am trying to use the Ocaml csv library. I downloaded csv-1.2.3 and followed the installation instructions after installing findlib:
Uncompress the source archive and go to the root of the package,
Run 'ocaml setup.ml -configure',
Run 'ocaml setup.ml -build',
Run 'ocaml setup.ml -install'
Now I have META, csv.a, csv.cma, csv.cmi, csv.cmx, csv.cmxa, csv.mli files in ~/opt/lib/ocaml/site-lib/csv repertory. The shell command ocamlfind list -describe gives csv A pure OCaml library to read and write CSV files. (version: 1.2.3) which I believe means that csv is installed properly.
BUT when I add
let data = Csv.load "foo.csv" in
in my compute.ml module and try to compile it within the larger program package I have the compilation error :
File "_none_", line 1, characters 0-1:
Error: No implementations provided for the following modules:
Csv referenced from compute.cmx"
and if I simply type
let data = load "foo.csv" in
i get :
File "compute.ml", line 74, characters 13-17:
Error: Unbound value load
I have the same type of errors when I use Csv.load or load directly in the Ocaml terminal. Would somebody have an idea of what is wrong in my code or library installation?
My guess is that you're using ocamlfind for compilation (ocamlfind ocamlc -package csv ...), because you have a linking error, not a type-checking one (which would be the case if you had not specified at all where csv is). The solution may be, in this case, to add a -linkall option to the final compilation line producing an executable, to ask it to link csv.cmx with it. Otherwise, please try to use ocamlfind and yes, tell us what your compilation command is.
For the toplevel, it is very easy to use ocamlfind from it. Watch this toplevel interaction:
% ocaml
Objective Caml version 3.12.1
# #use "topfind";;
- : unit = ()
Findlib has been successfully loaded. Additional directives:
#require "package";; to load a package
#list;; to list the available packages
#camlp4o;; to load camlp4 (standard syntax)
#camlp4r;; to load camlp4 (revised syntax)
#predicates "p,q,...";; to set these predicates
Topfind.reset();; to force that packages will be reloaded
#thread;; to enable threads
- : unit = ()
# #require "csv";;
/usr/lib/ocaml/csv: added to search path
/usr/lib/ocaml/csv/csv.cma: loaded
# Csv.load;;
- : ?separator:char -> ?excel_tricks:bool -> string -> Csv.t = <fun>
To be explicit. What I typed once in the toplevel was:
#use "topfind";;
#require "csv";;
Csv.load;; (* or anything else that uses Csv *)