Custom Task not visible in SSIS Toolbox - sql-server

I followed a tutorial in a Packt-Publishing Book to create a custom task. The book is about SQL Server 2012 Integration Services. Now I have SQL Server 2016 - maybe this makes a difference.
I was able to write a simple class for a task, that should delay execution for a given period of time.
My class inherits from Microsoft.SqlServer.Dts.Runtime.Task and overides the methods Execute, InitializeTask and Validate
I added the following class-decoration:
[DtsTask
(
DisplayName ="Delay Task",
Description ="Just a test",
IconResource ="Hourglass.ico",
RequiredProductLevel =DTSProductLevel.None,
TaskContact ="DelayTask"
)]
In Project properties I signed the assembly and added the following Post-Build script:
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\gacutil.exe" /u "$(TargetName)"
"C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\gacutil.exe" /if "$(TargetPath)"
copy "$(TargetPath)" "C:\Program Files\Microsoft SQL Server\130\DTS\Tasks" /Y
I can Build the Assembly without any issues and can see it in the target folder. Additionally I also copied the assembly in the x86 Program folder.
Unfortunately I cannot see the Task in the SSIS-Toolbox!
How can I deal with that??

Found the reason after hours of investigation.
I simple did not make the class public - blame on me !!!
Must be
public class DelayTask : Task {...}
and not
class DelayTask : Task {...}

I still can't see it in toolbox, my class is set to public
[DtsTask(
DisplayName = "Sales Force Import Task",
Description = "Pulls data from Sales Force",
UITypeName = "SForceLibrary.UI.SampleComponentUI, SForceLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f3a0d54ac94632fc",
TaskType = "ImportTask",
TaskContact = "ImportTask; InvenTrust Properties; Custom Sales Force Task",
RequiredProductLevel = DTSProductLevel.None
)]
public class ImportTask : Task

Related

Execute cutom javascript in report server

I followed this blog to insert custom javascript into my report.
I open report properties and referenced the library "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7.2\System.Web.dll".
I copied System.Web.dll to "\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER\Reporting Services\ReportServer\bin"
Under report properties > code I add the function:
Function WriteHTML (ByVal Msg AS String) AS String
System.Web.HttpContext.Current.Response.Write(Msg)
Return “”
End Function
Inserted a hidden textbox to the report and set expression to:
Code.WriteHTML("<script> console.log('hello world');</script>")
5 ) I deployed the report without any error.
But if I run the report in the browser no output is written to browser console. Any suggestions, do I miss something? Do I have to edit the rssrvpolicy.config as it mentioned here under point 3?
I found a second tutorial which describes an other method to execute a custom script in your report. But in my case I can't find any js file under "\Program Files\Microsoft SQL Server\MSRS13.MSSQLSERVER".

Is this a good way to reference Thinktecture DLLs from a strongly-named .NET DLL?

PROBLEM:
I am trying to help a co-worker who wants to reference Thinktecture.IdentityModel.Client.Net45.dll from a VB.NET DLL –- call it MyVBNet.dll -- that is strongly-named. When we run an executable that references MyVBNet.dll, MyVBNet.dll’s attempt to instantiate a Thinktecture object results in the following exception:
FileLoadException was unhandled by user code
An exception of type 'System.IO.FileLoadException' occurred in MyVBNet.dll but was not handled in user code
Additional information: Could not load file or assembly 'Thinktecture.IdentityModel.Client.Net45, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)
Here is code that I added to the constructor of an object in MyVBNet.dll to reproduce the exception above:
Dim lobjURI = New Uri("http://localhost:4200/")
Dim lobjOAuth2Client = New Thinktecture.IdentityModel.Client.OAuth2Client(lobjURI)
POTENTIAL WORKAROUND:
I tried to work around the problem as follows and afterward was able to instantiate a Thinktecture OAuth2Client object in MyVBNet.dll on a Windows 10 computer. However, I do not know whether this is a good approach.
[1] Find a Developer Command Prompt in the Start menu and do "[right click] > Run as administrator" on it.
[2] In the resulting window, if you do not already have a SNK file with a strong name key, key in something similar to the following to create an SNK file, keyPair2.snk in the example:
sn -k keyPair2.snk
[3] Copy a Thinktecture DLL to a directory, cd the Developer Command Prompt window to that directory, and key in the following, where Thinktecture.IdentityServer3.dll is an example of a Thinktecture DLL:
ildasm Thinktecture.IdentityServer3.dll /output:Thinktecture.IdentityServer3.il
move Thinktecture.IdentityServer3.dll Thinktecture.IdentityServer3.dll_Original
ilasm Thinktecture.IdentityServer3.il /dll /res:Thinktecture.IdentityServer3.res /key=keyPair2.snk
gacutil /i Thinktecture.IdentityServer3.dll
[4] In Visual Studio, remove your current references to Thinktecture DLLs and replace them by doing "[right click] > Add Reference... > Browse..." on the References node in the Solution Explorer for the assembly to which you wish to add a reference. Then select the DLL that you want under C:\Windows\Microsoft.NET\assembly\GAC_MSIL.

Unable to start Markdown interpreter in Zeppelin Notebook

When I try to use it I get the following error:
java.lang.ClassNotFoundException: org.apache.zeppelin.markdown.Markdown
With install-interpreter.sh -l I do see that md is listed there. So the interpreter is properly installed. I can also select it when creating new notebook as the "default interpreter". However, when I try to evaluate any cell using %md I get his class not found exception.
For some reason the interpreter is not included in the class path ... Any suggestion?
Content of interpreter/md/zeppelin-markdown-0.7.1.jar:
META-INF/
META-INF/MANIFEST.MF
org/
org/apache/
org/apache/zeppelin/
org/apache/zeppelin/markdown/
interpreter-setting.json
META-INF/DEPENDENCIES
META-INF/LICENSE
META-INF/NOTICE
org/apache/zeppelin/markdown/Markdown$1.class
org/apache/zeppelin/markdown/Markdown$MarkdownParserType$1.class
org/apache/zeppelin/markdown/Markdown$MarkdownParserType$2.class
org/apache/zeppelin/markdown/Markdown$MarkdownParserType.class
org/apache/zeppelin/markdown/Markdown.class
org/apache/zeppelin/markdown/Markdown4jParser.class
org/apache/zeppelin/markdown/MarkdownParser.class
org/apache/zeppelin/markdown/ParamVar.class
org/apache/zeppelin/markdown/PegdownParser.class
org/apache/zeppelin/markdown/PegdownWebSequencelPlugin.class
org/apache/zeppelin/markdown/PegdownYumlPlugin.class
META-INF/maven/
META-INF/maven/org.apache.zeppelin/
META-INF/maven/org.apache.zeppelin/zeppelin-markdown/
META-INF/maven/org.apache.zeppelin/zeppelin-markdown/pom.xml
META-INF/maven/org.apache.zeppelin/zeppelin-markdown/pom.properties
Since you have the markdown interpreter install , you just need to create a new Interpreter binding for the markdown.
To create a new binding for markdown
Click the settings button
Binding Setting
Click on the interpreter menu
Interpreter menu
Click on the create buttom
Create button
Give Interpreter name as md and Interpreter group as md then save
Adding binding
Go back to the notebook and add md binding to notebook and save Adding interpreter to notebook
Now %md should start your markdown Interpreter
I noticed that they were quite a lot "zombie" Zeppelin processes running on my machine. After killing them, it seems that this problem went away.

Can I force the installer project to use the .config file from the built solution instead of the original one?

I am using the solution to this question in order to apply configuration changes to App.config in a Winforms project. I also have an installer project for the project that creates an installable *.msi file. The problem is, the config file bundled in the installers is the original, un-transformed config file. So we're not getting the production connection strings in the production installer even though the config file for the built winforms project has all the correct transformations applied.
Is there any way to force the installer project to use the output of project build?
First of all: it is impossible to make the Setup Project point to another app.config file by using the Primary output option. So my solution is going to be a work around. I hope you find it useful in your situation.
Overview:
The basic idea is:
Remove the forced app.config from the Setup Project;
Add a file pointing to the app.config, manually;
Use MSBuild to get into the vdproj file, and change it to match the real output of the transformed app.config.
Some drawbacks are:
The setup project only gets updated, if the project it deploys build. ahhh... not a real drawback!
You need MSBuild 4.0... this can also be worked around!
Need a custom Task, called FileUpdate... it is open source and has installer.
Lets Work:
1) Go to your Setup Project, and select the Primary Output object, right click and go to Properties. There you will find the Exclude Filter... add a filter for *.config, so it will remove the hard-coded app.config.
2) Right click your Setup Project in the Solution Explorer -> Add -> File... select any file that ends with .config.
3) Download MSBuild Community Tasks Project, I recomend the msi installer.
4) Unload your project (the csproj) and replace the code from the other question with this one:
Code:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />
<Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')">
<!-- Generate transformed app config in the intermediate directory -->
<TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
<!-- Force build process to use the transformed configuration file from now on. -->
<ItemGroup>
<AppConfigWithTargetPath Remove="app.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
<PropertyGroup>
<SetupProjectPath>$(MSBuildProjectDirectory)\$(IntermediateOutputPath)$(TargetFileName).config</SetupProjectPath>
</PropertyGroup>
<!-- Change the following so that this Task can find your vdproj file -->
<FileUpdate Files="$(MSBuildProjectDirectory)\..\Setup1\Setup1.vdproj"
Regex="(.SourcePath. = .8:).*\.config(.)"
ReplacementText="$1$(SetupProjectPath.Replace(`\`,`\\`))$2" />
<FileUpdate Files="$(MSBuildProjectDirectory)\..\Setup1\Setup1.vdproj"
Regex="(.TargetName. = .8:).*\.config(.)"
ReplacementText="$1$(TargetFileName).config$2" />
</Target>
5) The previous code must be changed, so that it can find your vdproj file. I have placed a comment in the code, indicating where you need to make the change.
Now, everytime you build your main project, the MSBuild will change the Setup project, so that it uses the correct app.config file. It may have drawbacks, but this solution can be polished and become better. If you need leave a comment, and I'll try to respond ASAP.
Resources I Used
MSBuild 4.0 is needed because I need to use String's Replace function, to replace single "\" to double "\" in the path. See
MSBuild Property Functions for details about using function in MSBuild.
I learned about the FileUpdate Task in this other question. The official project is MSBuild Community Tasks Project.
These two topics were important to my findings:
Trying to include configuration specific app.config files in a setup project
Problems with setup project - am I thick?
Another solution I've found is not to use the transformations but just have a separate config file, e.g. app.Release.config. Then add this line to your csproj file.
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<AppConfig>App.Release.config</AppConfig>
</PropertyGroup>
This will force the deployment project to use the correct config file when packaging.
I combined the best of the following answers to get a fully working solution without using any external tools at all:
1. Setup App.Config transformations
Source: https://stackoverflow.com/a/5109530
In short:
Manually add additional .config files for each build configuration and edit the raw project file to include them similar to this:
<Content Include="App.config" />
<Content Include="App.Debug.config" >
<DependentUpon>App.config</DependentUpon>
</Content>
<Content Include="App.Release.config" >
<DependentUpon>App.config</DependentUpon>
</Content>
Then include the following XML at the end of the project file, just before the closing </project> tag:
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists('app.$(Configuration).config')">
<TransformXml Source="app.config" Destination="$(IntermediateOutputPath)$(TargetFileName).config" Transform="app.$(Configuration).config" />
<ItemGroup>
<AppConfigWithTargetPath Remove="app.config" />
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
Finally edit the additional .config files to include the respective transformations for each build configuration:
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<!-- transformations here-->
</configuration>
2. Include the appropriate .config in the setup project
First, add a command in the postbuild event of your main project to move the appropriate transformed .config file to a neutral location (e.g. the main bin\ directory):
copy /y "$(TargetDir)$(TargetFileName).config" "$(ProjectDir)bin\$(TargetFileName).config"
(Source: https://stackoverflow.com/a/26521986)
Open the setup project and click the "Primary output..." node to display the properties window. There, add an ExludeFilter "*.config" to exclude the default (untransformed) .config file.
(Source: https://stackoverflow.com/a/6908477)
Finally add the transformed .config file (from the postbuild event) to the setup project (Add > File).
Done.
You can now freely add build configurations and corresponding config transforms and your setup project will always include the appropriate .config for the active configuration.
I accomplished this in a different manner with no external tools:
I added a post-build event that copied the target files to a 'neutral' directory (the root of the /bin folder in the project) and then added this file to the .vdproj. The deployment project now picks up whatever the latest built version is:
Post Build Command:
copy /y "$(TargetDir)$(TargetFileName).config" "$(ProjectDir)bin\$(TargetFileName).config"
This worked for what I needed without any external tools, and works nicely with SlowCheetah transformations.
Based off Alec's answer, here is a similar element that you can use along with the transformations and still get their full benefit:
<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Content Include="$(OutputPath)$(AssemblyName).dll.config">
<InProject>false</InProject>
<Link>$(AssemblyName).dll.config</Link>
</Content>
</ItemGroup>
This way, you can use the SlowCheetah transforms or the built-in ones to transform your .config file, and then go into your Visual Studio Deployment Project (or other) and include the Content from the affected project in your Add -> Project Output... page easily, with minimal changes.
None of the above solutions or any articles worked for me in deployment/setup project. Spent many days to figure out the right solution. Finally this approach worked for me.
Pre requisites
I've used utility called cct.exe to transform file explicitly. You can download from here
http://ctt.codeplex.com/
I've used custom installer in setup project to capture installation events.
Follow these steps to achieve app config transformation
1) Add your desired config files to your project and modify your .csproj file like these
<Content Include="app.uat.config">
<DependentUpon>app.config</DependentUpon>
</Content>
<Content Include="app.training.config">
<DependentUpon>app.config</DependentUpon>
</Content>
<Content Include="app.live.config">
<DependentUpon>app.config</DependentUpon>
</Content>
I've added them as content so that they can be copied to output directory.
2) Add cct.exe to your project which you downloaded.
3) Add custom installer to your project which should look like this
[RunInstaller(true)]
public partial class CustomInstaller : System.Configuration.Install.Installer
{
string currentLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string[] transformationfiles = Directory.GetFiles(Path.GetDirectoryNam(Assembly.GetExecutingAssembly().Location), "app.*.config");
public CustomInstaller()
{
InitializeComponent();
// Attach the 'Committed' event.
this.Committed += new InstallEventHandler(MyInstaller_Committed);
this.AfterInstall += new InstallEventHandler(CustomInstaller_AfterInstall);
}
void CustomInstaller_AfterInstall(object sender, InstallEventArgs e)
{
try
{
Directory.SetCurrentDirectory(currentLocation);
var environment = Context.Parameters["Environment"];
var currentconfig = transformationfiles.Where(x => x.Contains(environment)).First();
if (currentconfig != null)
{
FileInfo finfo = new FileInfo(currentconfig);
if (finfo != null)
{
var commands = string.Format(#"/C ctt.exe s:yourexename.exe.config t:{0} d:yourexename.exe.config ", finfo.Name);
using (System.Diagnostics.Process execute = new System.Diagnostics.Process())
{
execute.StartInfo.FileName = "cmd.exe";
execute.StartInfo.RedirectStandardError = true;
execute.StartInfo.RedirectStandardInput = true;
execute.StartInfo.RedirectStandardOutput = true;
execute.StartInfo.UseShellExecute = false;
execute.StartInfo.CreateNoWindow = true;
execute.StartInfo.Arguments = commands;
execute.Start();
}
}
}
}
catch
{
// Do nothing...
}
}
// Event handler for 'Committed' event.
private void MyInstaller_Committed(object sender, InstallEventArgs e)
{
XmlDocument doc = new XmlDocument();
var execonfigPath = currentLocation + #"\yourexe.exe.config";
var file = File.OpenText(execonfigPath);
var xml = file.ReadToEnd();
file.Close();
doc.LoadXml(FormatXmlString(xml));
doc.Save(execonfigPath);
foreach (var filename in transformationfiles)
File.Delete(filename);
}
private static string FormatXmlString(string xmlString)
{
System.Xml.Linq.XElement element = System.Xml.Linq.XElement.Parse(xmlString);
return element.ToString();
}
}
Here I am using two event handlers CustomInstaller_AfterInstall in which I am loading correct config file and transforming .
In MyInstaller_Committed I am deleting transformation files which we don't need on client machine once we apply has been applied. I am also indenting transformed file because cct simply transforms elements were aligned ugly.
4) Open your setup project and add project output content file so that setup can copy config files like app.uat.config,app.live.config etc into client machine.
In previous step this snippet will load all available config files but we need supply right transform file
string[] transformationfiles = Directory.GetFiles(Path.GetDirectoryNam
(Assembly.GetExecutingAssembly().Location), "app.*.config");
For that I've added UI dialog on setup project to get the current config. The dialog gives options for user to select environment like "Live" "UAT" "Test" etc .
Now pass the selected environment to your custom installer and filter them.
It will become lengthy article if I explain on how to add dialog,how to set up params etc so please google them. But idea is to transform user selected environment.
The advantage of this approach is you can use same setup file for any environment.
Here is the summary:
Add config files
Add cct exe file
Add custom installer
Apply transformation on exe.config under after install event
Delete transformation files from client's machine
Modify setup project in such a way that
set up should copy all config files(project output content) and cct.exe into output directory
configure UI dialog with radio buttons (Test,Live,UAT..)
pass the selected value to custom installer
Solution might look lengthy but have no choice because MSI always copy app.config and doesn't care about project build events and transformations. slowcheetah works only with clickonce not setup project
The question is old, but the following could still help many folks out there.
I would simply use Wix WiFile.exe to replace the concerned file in the msi this way (for the sake of this example, we call your msi yourPackage.msi):
Step 1. From command prompt run: WiFile.exe "yourPackage.msi" /x "app.exe.config."
The above will extract the "wrong" app.exe.config file from the msi and place it the same directory as your msi;
Step 2. Place the new (prod) config file (must have the same name as the extracted file: app.exe.config) in same location as your msi;
This means that you are overwritting the app.exe.config that has just been extracted in step 1 above, with your new (production config file);
Step 3. From command prompt run: WiFile.exe "yourPackage.msi" /u "app.exe.config."
THAT'S ALL!
The above can be done in a few seconds. You could automate the task if you wanted, for instance, by running it as batch or else.
After running step 3 above, your msi will contain the new config file, which will now be installed at your clients' when they run the setup.

Silverlight unit testing. Error while running tests

I'm using VS2010. Silverlight 4, NUnit 2.5.5, and TypeMock
TypemockIsolatorSetup6.0.3.619.msi
In the test project MVVM is implemented, PeopleViewModel is a ViewModel which I want to test.
Please advise if you use other products for unit testing of MVVM Silverlight. Or please help to win this TypeMock. TIA
This is the code of the test:
[Test]
[SilverlightUnitTest]
public void SomeTestAgainstSilverlight()
{
PeopleViewModel o = new PeopleViewModel();
var res = o.People;
Assert.AreEqual(15, res.Count());
}
While running the test in ReSharper i get the following error:
TestA.SomeTestAgainstSilverlight : Failed******************************************
*Loading Silverlight Isolation Aspects...*
******************************************
TEST RESULTS:
---------------------------------------------
System.MissingMethodException : Method not found: 'hv TypeMock.ArrangeActAssert.Isolate.a(System.Delegate)'.
at a4.a(ref Delegate A_0)
at a4.a(Boolean A_0)
at il.b()
at CThru.Silverlight.SilverlightUnitTestAttribute.Init()
at CThru.Silverlight.SilverlightUnitTestAttribute.Execute()
at TypeMock.MockManager.a(String A_0, String A_1, Object A_2, Object A_3, Boolean A_4, Object[] A_5)
at TypeMock.InternalMockManager.getReturn(Object that, String typeName, String methodName, Object methodParameters, Boolean isInjected)
at Tests.TestA.SomeTestAgainstSilverlight() in TestA.cs: line 21
While running test in NUnit i get:
Tests.TestA.SomeTestAgainstSilverlight:
System.DllNotFoundException : Unable to load DLL 'agcore': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at MS.Internal.XcpImports.Application_GetCurrentNative(IntPtr context, IntPtr& obj)
at MS.Internal.XcpImports.Application_GetCurrent(IntPtr& pApp)
at System.Windows.Application.get_Current()
at ViewModelExample.ViewModel.ViewModelBase.get_IsDesignTime() in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\ViewModelBase.cs:line 20
at ViewModelExample.ViewModel.PeopleViewModel..ctor(IServiceAgent serviceAgent) in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\PeopleViewModel.cs:line 28
at ViewModelExample.ViewModel.PeopleViewModel..ctor() in C:\Documents and Settings\USER\Desktop\ViewModelExample\ViewModelExample\ViewModel\PeopleViewModel.cs:line 24
at Tests.TestA.SomeTestAgainstSilverlight() in C:\Documents and Settings\USER\Desktop\ViewModelExample\Tests\TestA.cs:line 22
UPDATE: I'm not following the question. I've switched to other tools.
This message looks like a mismatched files issue. Try creating a new test project from scratch.
Start by adding references to Typemock.dll and Typemock.ArrangeActAssert.dll. From the CThru directory add both CThru.dll and CThru.Silverlight.dll.
Add a reference to System.Windows (located at C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\System.Windows.dll).
Try creating a new test method, and decorate it with SilverlightUnitTest attribute:
using NUnit.Framework;
using CThru.Silverlight;
[TestFixture]
public class SilverlightTest
{
[Test, SilverlightUnitTest]
public void EmptyTest()
{
}
}
Run this empty test. If you're still having the problem you described, please contact support at typemock.com for further assistance.

Resources