Recently I was looking at couple of products to obfuscate C# code and came across Obfuscar.
You can run Obfuscar via a command line or on the Post Build Events in Visual Studio.
There are a few steps to add this to the post build of any project.
1. Add Obfuscar NuGet Package to your solution.
2. Add obfuscar.xml file to your project and change Copy to Output Directory: Always.
In this config I want to obfuscate a DLL for a blockchain project I am working on.
<?xml version='1.0'?>
<Obfuscator>
<Var name="InPath" value="C:...[path to your project output folder]" />
<Var name="OutPath" value="$(InPath)\Obfuscator_Output" />
<Var name="KeepPublicApi" value="false" />
<Var name="HidePrivateApi" value="true" />
<Var name="RenameProperties" value="true" />
<Var name="RenameEvents" value="true" />
<Var name="RenameFields" value="true" />
<Var name="UseUnicodeNames" value="true" />
<Var name="HideStrings" value="true" />
<Var name="OptimizeMethods" value="true" />
<Var name="SuppressIldasm" value="true" />
<Module file="$(InPath)\CoinControl.dll" />
</Obfuscator>
3. In the Visual Studio post build events enter: "$(Obfuscar)" obfuscar.xml
After you run the build (in your debug or release folder) you will have a fully obfuscated binary under a folder named: Obfuscator_Output.
I had a solution with 5 projects but two were in source control but never showed as checked out.
I was looking for a way to "bind" these to TFS that option was not showing up. This link shows how to do it.
To bind source control projects and solutions to Visual Studio
-
Highlight the project or solution you wish to bind to Team Foundation source control in Solution Explorer.
-
From the File menu, choose Source Control, and then choose Change Source Control.
-
In Change Source Control dialog box, click Bind.
To unbind source control projects and solutions to Visual Studio
-
Highlight the project or solution you wish to unbind in Team Foundation source control in Solution Explorer.
-
From the File menu, choose Source Control, and then choose Change Source Control.
-
In the Change Source Control dialog box, highlight the solution or project you wish to unbind from source control, and in the toolbar, click Unbind.
I am able to successful runs MSTest unit tests in Visual Studio 2017 but it would not run on the TFS 2018 server (or TFS 2015 before I upgraded).
While setting up TFS 2018 to run unit tests I was getting the following warnings.
Warning: [MSTest][Discovery][C:\Agent\_work\2\s\[......]
Warning: No test is available in C:\Agent\_work\2\s\[......]
Information: Additionally, you can try specifying '/UseVsixExtensions' command if the test discoverer & executor is installed on the machine as vsix extensions and your installation supports vsix extensions.
##[warning]No results found to publish.
##[section]Finishing: VsTest - testAssemblies
THE FIX
By default the "Search folder" was set to $(System.DefaultWorkingDirectory) that path was looking at c:\agent\_work\2\s\MyProject.Tests\obj\Release\MyProject.Tests.dll but that folder did not have the following DLLs.
Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll
Changing the "Search folder" to $(Build.StagingDirectory) corrected the issue and the test ran successfully.
Here are are the tasks in the build.
Here is where the value for the path had to be updated.