WIX 3.7 call WebService in CustomActions - web-services

I am using Visual Studio 2013 and WIX 3.7. I need to call a WebService Method when the Application is Unistall.
Everything is correctly defined in .WXS file. I have the correct webreference int the Project. The problem is that the WebService reference does not ejecuted.
[CustomAction]
public static ActionResult CheckPID(Session session)
{
Directory.Delete(#"C:\BBB");//IT IS EJECUTED
ServiceClient serviceClient = new ServiceClient();//ERROR
Directory.Delete(#"C:\AAA");//IT DOES NOT EJECUTED
return ActionResult.Success;
}
Any idea how can I make a it Works?
Thanks

Related

Visual Studio for Mac not running unit tests from MSTest project

I've created a .NET Core 6 Web API project in Visual Studio for Mac. I can run the web API without issues and can interact with it using Swagger. I'm now attempting to create a MSTest project and write unit tests. I've written one however when I attempt to run it, Visual Studio for Mac appears not to do anything like so:
Unit Test:
namespace Tests;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void ExampleTest()
{
var text = "hello.";
var result = text.ToUpperInvariant();
Assert.AreEqual("HELLO.", result);
}
}
Any ideas on what I'm missing?

Need to Programmatically Recompile all Script Tasks in DTSX Packages after Mass Find-And-Replace

An upcoming move of our Data Warehouse has us needing to change many Connection Strings and UNC File Paths located in VBA Script Tasks within DTSX Packages.
We've performed a mass find-and-replace but when changing Script Tasks using this method, the binaries run during DTSX Package execution don't get recompiled at run time, resulting in the find-and-replaced changes not being reflected in the Script Task's execution.
I've found some articles on how to do it in SQL Server 2008 and 2012, but we're using SQL Server 2014 and the code examples here aren't working for me:(https://blogs.msdn.microsoft.com/jason_howell/2013/03/05/script-component-recompile-in-sql-server-2012-integration-services-ssis-to-refresh-metadata/).
Some of the questions in the comments speak to my problem but none of the "I fixed this this way [navigate to path and include references]" are working for me -- I don't see these assemblies, and with the changes between 2008 to 2012, and now us on 2014, I'm uncertain whether these libraries are even included in my distribution...
So, I have a whole bunch of DTSX files in various sub directories that require their script tasks be recompiled in order for us to go live with these changes.
I'm hoping to not-have to open every script task in every package manually to force the build of each task.
Thanks in advance for any potential solutions!
I create a Console application with the code necesary to recompile every ScriptTask inside a dtsx package, using Visual Studio 2013 and C# up to two levels. Path for every assembly that needs to be referenced are included as comments in the code. pkgLocation is the path to the package(in the ends I build a Windows Form app, but this is the base and working code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SqlServer.Dts.Design;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Pipeline;
using Microsoft.SqlServer.VSTAHosting;
using Microsoft.SqlServer.IntegrationServices.VSTA;
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;
using System.IO;
//Libraries
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.Dts.Design\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.Dts.Design.dll
//C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SqlServer.DTSPipelineWrap.dll
//C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SQLServer.DTSRuntimeWrap.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.IntegrationServices.VSTA\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.IntegrationServices.VSTA.dll
//C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies\Microsoft.SQLServer.ManagedDTS.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.PipelineHost\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SQLServer.PipelineHost.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.ScriptTask\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.ScriptTask.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.TxScript\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.TxScript.dll
//C:\windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SqlServer.VSTAScriptingLib\v4.0_12.0.0.0__89845dcd8080cc91\Microsoft.SqlServer.VSTAScriptingLib.dll
namespace recompApp
{
class Program
{
static void Main(string[] args)
{
string pkgLocation;
Package pkg;
Application app;
//This is the folder where the test package lives!!
pkgLocation =
#"C:\TestPackage.dtsx";
app = new Application();
pkg = app.LoadPackage(pkgLocation, null);
//It's Alive!!!!!!!
try
{
Executables pExecs = pkg.Executables;
foreach (Executable pExec in pExecs)
{
switch (pExec.GetType().Name)
{
case "TaskHost":{
TaskHost taskHost = (TaskHost)pExec;
Console.WriteLine("Executable name = " + taskHost.Name);
//Script Task Outside of a Sequence
if (taskHost.InnerObject.ToString().Equals("Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptTask"))
{
ScriptTask task = (ScriptTask)taskHost.InnerObject;
//Load the script project, build and save
task.ScriptingEngine.LoadProjectFromStorage();
task.ScriptingEngine.VstaHelper.Build("");
task.ScriptingEngine.SaveProjectToStorage();
//Cleanup
task.ScriptingEngine.DisposeVstaHelper();
}
break;
}
case "Sequence":{
Executables seqExecs = ((Microsoft.SqlServer.Dts.Runtime.Sequence)(pExec)).Executables;
foreach(Executable seqExec in seqExecs){
switch (seqExec.GetType().Name)
{
case "TaskHost":
{
TaskHost taskHost = (TaskHost)seqExec;
//Script Task inside a Sequence Container
if (taskHost.InnerObject.ToString().Equals("Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptTask"))
{
Console.WriteLine("Executable name = " + taskHost.Name);
ScriptTask task = (ScriptTask)taskHost.InnerObject;
//Load the script project, build and save
task.ScriptingEngine.LoadProjectFromStorage();
task.ScriptingEngine.VstaHelper.Build("");
task.ScriptingEngine.SaveProjectToStorage();
//Cleanup
task.ScriptingEngine.DisposeVstaHelper();
}
break;
}
}
}
break;
}
}
}
//Save the updated xml in the package
string xml;
pkg.SaveToXML(out xml, null);
File.WriteAllText(pkgLocation, xml);
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
}
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
I hope this helps a lots of people outside. I also have the Visual Basic version if you need it.

Issues using DataTestMethod and DataRow attributes in MS Test

I have installed MS Test V2 in my VS 2015 instance using nuGet and I have successfully added DataTestMethod and DataRow attributes to my unit tests and they compile, but now when I build, the tests don't show up in Test Explorer.
Example:
[DataTestMethod]
[DataRow("YAHOO", "GOOGLE")]
public void TestCheckSite(string site)
{
... do stuff here ...
}
What am I missing? Is there a Test Explorer upgrade?
[DataTestMethod]
[DataRow("YAHOO")]
[DataRow("GOOGLE")]
public void TestCheckSite(string site) {
...
}
Install MSTest Framework: https://www.nuget.org/packages/MSTest.TestFramework/
If you are building for .NET Core, then install this adapter: https://www.nuget.org/packages/dotnet-test-mstest/
However, if you are building for desktop .NET/UWP, install this adapter instead: https://www.nuget.org/packages/MSTest.TestAdapter/
Now write the tests and build your solution. The tests ought to show up in the Test Explorer.
Please let me know if you still do not see the tests showing up.

How to reference LeadTools to Unit Test project?

Evaluating Document Imaging SDK, I'm trying to create a unit test project in my Visual Studio 2012 to check some code snippets. I have referenced LeadTools dlls from installation directory 'C:\LEADTOOLS 18\Bin\Dotnet4\Win32' and pointed my unt test project output directory to the same directory (to have all LeadTools binaries next to my output). But running the unit test I'm getting the following execption:
Test method
LeadTools.Evaluation.UnitTests.Snippets.PdfToTiffTest.PdfToTiffTest
threw exception: Leadtools.RasterException: Raster PDF Engine is
needed to use this feature
I suspect that problem is caused by VSTest process is running outside the 'C:\LEADTOOLS 18\Bin\Dotnet4\Win32' and can' find necessary LeadTools binaries.
Question: What is the correct way of refencing LeadTools binaries to the test project?
Unit test code:
using System.IO;
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Pdf;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace LeadTools.Evaluation.UnitTests.Snippets
{
[TestClass]
public class PdfToTiffTest
{
[TestMethod]
public void PdfToTiffTest()
{
const string pdfPath = "C:\Samples\source.pdf";
var tiffPath = Path.ChangeExtension(pdfPath, "tiff");
// Load the input PDF document
var document = new PDFDocument(pdfPath);
using (var codecs = new RasterCodecs())
{
// Loop through all the pages in the document
for (var page = 1; page <= document.Pages.Count; page++)
{
// Render the page into a raster image
using (var image = document.GetPageImage(codecs, page))
{
// Append to (or create if it does not exist) a TIFF file
codecs.Save(image, tiffPath, RasterImageFormat.TifJpeg, 24, 1, 1, -1, CodecsSavePageMode.Append);
}
}
}
}
}
}
In VS 2010 that was possible to specify where to resolve assemplies right in Test Settings. To do that in VS 2012, you could do that in App.config as described in this post Assembly Resolution for Unit Tests by Visual Studio Test Team.
Just add app.config to your test project and put there the appropriate <AssemblyResolution> details.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="TestExecution" type="Microsoft.VisualStudio.TestTools.Execution.TestExecutionSection, Microsoft.VisualStudio.QualityTools.ExecutionCommon, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>
<TestExecution xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<AssemblyResolution>
<RuntimeResolution>
<Directory path="%ProgramFiles%\SampleApplication\" includeSubDirectories="true"/>
</RuntimeResolution>
</AssemblyResolution>
</TestExecution>
</configuration>

Unit Testing for Windows Phone 7 - App does not launch correctly

I am developing a Wp7-App and I want to start Unit Testing. I used the Template from Visual Studio 2010 to create a Windows Phone 7.1 UnitTest-Project and I added the required Assemblies via Nu-Manager.
I can't start the project in emulator or on a real device. I get a blank loading-screen and this error message:
A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll
Is this a known error? Is there a workaround?
Thanks!
The standard VS Unit test template won't work for WP7. You should look at these links:
http://channel9.msdn.com/Events/MIX/MIX10/CL59
and
http://www.jeff.wilcox.name/2011/06/updated-ut-mango-bits/
I have a Silverlight 4 Test Project using the Jeff Wilcox assemblies and it works fine for my WP7 tests. I use [TestClass] and [TestMethod] attributes and these namespaces inside my tests:
using Microsoft.Silverlight.Testing; using
Microsoft.VisualStudio.TestTools.UnitTesting;
Within the App.xaml.cs file there is minimal code and the following starts it all off:
private void Application_Startup(object sender, StartupEventArgs e)
{
RootVisual = UnitTestSystem.CreateTestPage();
}