I have the following task in my nant script:
<nunit2 verbose="true">
<formatter type="Plain" />
<test assemblyname="${output}\Test.dll" appconfig="${project.src.root}\Test\Test.config"/>
</nunit2>
Test.config is the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
<bindingRedirect oldVersion="2.5.3.9345" newVersion="2.2.8.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I get an error when i run this task saying could not load nunit.framework. I know nunit is not in the GAC (not strongly signed). Does Nunit have to be in the GAC for this task to work?
I provide the path to my NUnit binary during compilation. When I call nunit2, the reference to the framework is present and I don't get this error. Does this help?
<target name="unit.compile" depends="sharedClasses, helpers.compile" description="compiles the unit tests" >
<copy todir="build" flatten="true">
<fileset basedir="tools\NUnit-2.5.2.9222\framework">
<include name="nunit.framework.dll" />
</fileset>
</copy>
<csc target="library" output="build\${project::get-name()}.test.unit.dll" debug="${debug}">
<sources>
<include name="source\web\tests\unit\**\*.cs" />
<exclude name="source\web\tests\unit\**\AssemblyInfo.cs" />
</sources>
<references basedir="build" >
<include name="nunit.framework.dll" />
<include name="Microsoft.Practices.EnterpriseLibrary.Common.dll" />
<include name="Microsoft.Practices.EnterpriseLibrary.Data.dll" />
<include name="${project::get-name()}.sharedClasses.dll" />
<include name="${project::get-name()}.test.helpers.dll" />
</references>
</csc>
</target>
<target name="unit.test" depends="unit.compile, helpers.compile">
<copy file="configuration\Web.Config" tofile="build\${project::get-name()}.test.unit.dll.config" />
<copy file="configuration\ui_list.config" tofile="build\ui_list.test.config" />
<nunit2>
<test
assemblyname="build\${project::get-name()}.test.unit.dll"
appconfig="build\${project::get-name()}.test.unit.dll.config"
/>
<formatter type="Plain" />
</nunit2>
</target>
Set your Nant tasks to show with verbose output (often this means just adding 'verbose=true' to the applicable tasks) and see if you can verify the paths that it's trying to use to reference nunit.framework.dll.
It's very likely that the path to nunit.framework.dll in your project is a relative path that may not work when you try to run the task from NAnt via the command line. (for example, if your .csproj is nested in a folder but your Nant script is not, or if you're moving around the build outputs prior to testing).
Related
Is there any way to apply a web.config transform on more than one level? E.g:
web.config
- web.release.config
- web.prod1.config
- web.prod2.config
When targeting prod1, I would like to do a 3 way merge web.config < web.release.config < web.prod1.config. Is this possible?
There is a way to accomplish this. As you don't specify too much, I'm not sure this will satisfy your requirements though. The following is how it could be accomplished from scratch, but you could just pull the bits that you need directly into the csproj you already have.
Create a .csproj file:
Transform.csproj
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="Web.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Prod.config">
<DependentUpon>Web.config</DependentUpon>
</None>
<None Include="Web.Release.config">
<DependentUpon>Web.config</DependentUpon>
</None>
</ItemGroup>
<UsingTask TaskName="TransformXml" AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<Target Name="TransformRelease">
<TransformXml Source="Web.config"
Transform="Web.Release.config"
Destination="Web.New.config"/>
</Target>
<Target Name="TransformProd">
<TransformXml Source="Web.New.config"
Transform="Web.Prod.config"
Destination="Web.New.config"/>
</Target>
</Project>
Then you can execute your two transforms through invoking an msbuild command from the command line. I used the following powershell commands.
.\msbuild.exe "PATH_TO_YOUR_CSPROJ\Transform.csproj" /t:TransformRelease
.\msbuild.exe "PATH_TO_YOUR_CSPROJ\Transform.csproj" /t:TransformProd
This will transform your web.config using the transforms in the web.release.config and create a new file with the result of that transform web.new.config. Then the second command will transform the web.new.config using the transforms in web.prod.config and update the web.new.config with that transformed value.
Web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="web" value="web" />
<add key="release" value="web" />
<add key="prod" value="web" />
<add key="release:prod" value="web" />
</appSettings>
</configuration>
Web.Release.config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="release" value="release" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
<add key="release:prod" value="release" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
</appSettings>
</configuration>
Web.Prod.config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="prod" value="prod" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
<add key="release:prod" value="prod" xdt:Transform="SetAttributes" xdt:Locator="Match(key)" />
</appSettings>
</configuration>
Running the above commands produced Web.New.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="web" value="web" />
<add key="release" value="release" />
<add key="prod" value="prod" />
<add key="release:prod" value="prod" />
</appSettings>
</configuration>
UPDATE
While the above works, I wouldn't want to use it in that manner. After tinkering around with the .csproj a bit, I came up with this which will do the transformation for you in the BeforeBuild task.
<Target Name="TransformRelease">
<TransformXml Source="Web.config" Transform="Web.Release.config" Destination="Web.New.config" />
</Target>
<Target Name="TransformProd" Condition="'$(Configuration)' == 'Release'">
<TransformXml Source="Web.New.config" Transform="Web.Prod.config" Destination="Web.New.config" />
</Target>
<Target Name="BeforeBuild">
<MSBuild Projects="WebApplication1.csproj" Targets="TransformRelease;TransformProd"/>
</Target>
With these defined in your .csproj file, when you build the project as is, it will apply the Release transform alone. When you build the project in the Release configuration, it will apply both the Release and Prod transformations. Obviously you will need to tweak it for your needs given prod1, prod2, etc.
Is not possible out of the box with simple commands, but you can do custom transformation and string replacement using build tasks
A while ago I asked a similar questions and I got a really nice answer using build tasks transformation. Instead of copying it here, take a look in the solution and adapt to your needs.:
Service Fabric Default Publish Profile other than Local.xml
I am trying to do a little spike and I cannot get log file generated.
This is my NLog configuration:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Npgsql" publicKeyToken="5d8b90d52f46fda7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.2.4.0" newVersion="3.2.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<nlog throwExceptions="true"
internalLogLevel="Warning"
internalLogFile="Rebus.Tests.Output.NLog.Internal.log"
internalLogToConsole="true"
xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="normalLogfile" type="File" fileName="${basedir}/Rebus.Tests.Output.log" />
<target name="normalConsole" type="Console" detectConsoleAvailable="true" />
</targets>
<rules>
<logger name="NormalLog" minlevel="Trace" writeTo="normalLogfile, normalConsole" />
</rules>
</nlog>
</configuration>
And here is my static Main in the Console Application:
var logger = LogManager.GetLogger("NormalLog");
logger.Error("This is a log error line");
But nothing is logged neither LogFile nor Console.
The application.exe.config is in the bin/Debug runtime folder.
And I am looking for the log file with SearchEverything so it will found in any folder where it is.
Adding some information to this question if I put a breakpoint to inspect logger variable I can see no configuration was read:
Try to change
var logger = LogManager.GetLogger("NormalLog");
to
var logger = LogManager.GetLogger("normalLogfile");
because as far as I know you have to get the logger via target-name and not via rule-name.
//edit
Have you tried to remove the nlog attributes in you app.config? Just to be sure none of them is the problem.
I am following up the below link and setting a CI set up.
https://blogs.msdn.microsoft.com/visualstudioalm/2015/05/29/testing-in-continuous-integration-and-continuous-deployment-workflows/
The issue I am facing here is with respect to the test settings file. The test are running fine locally. But not remotely when running it, I am getting all test failures.
I believe this is because of the spreadsheet ( where the test data resides ) and the test settings file.
My test settings file is below
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="UITestSettings" id="1623gdcf4-f2af-496f-b65h4-fe25w6c4e49cb" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>These are default test settings for a remote test run.</Description>
<Deployment>
<DeploymentItem filename="XXX\TestData\LocationData.xls" />
<DeploymentItem filename="XXX\TestData\UITestData.xls" />
</Deployment>
<Execution parallelTestCount="0">
<Timeouts runTimeout="36610000" testTimeout="36610000" />
<TestTypeSpecific>
<UnitTestRunConfig testTypeId="13cdcs9d9-ddb5-4fa4-a97d-d965ccdfc6d4b">
<AssemblyResolution>
<TestDirectory useLoadContext="true" />
</AssemblyResolution>
</UnitTestRunConfig>
<WebTestRunConfiguration testTypeId="4ess7599fa-5ecb-43e9-a887-cd63cfdf72d207">
<Browser name="Internet Explorer 9.0" MaxConnections="6">
<Headers>
<Header name="User-Agent" value="Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" />
<Header name="Accept" value="*/*" />
<Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
<Header name="Accept-Encoding" value="GZIP" />
</Headers>
</Browser>
</WebTestRunConfiguration>
</TestTypeSpecific>
<AgentRule name="LocalMachineDefaultRole">
</AgentRule>
</Execution>
<Properties>
<Property name="TestSettingsUIType" value="UnitTest" />
</Properties>
</TestSettings>
All test failed with this error
Data source 'XXX.YYY.aboutThemRecommendationFirstQuarterFlows' cannot be found in the test configuration settings
But I have the settings file in the build steps ( in Run functional Step )
Is there anything I am missing. Any help would be great as I am struggling to find a solutions.
Thanks
According to the error message, it seems that you are referring to a data source named as "XXX.YYY.aboutThemRecommendationFirstQuarterFlows" which does not exist in "App.config" file test configuration settings.
For example, I have a test method use "MyExcelDataSourceTTT" data source:
[TestMethod]
[DataSource("MyExcelDataSourceTTT")]
public void TestMethod1()
{
Assert.AreEqual(TestContext.DataRow["1"].ToString(),"1");
}
But in the App.config file, I only have "MyExcelDataSource" data source. "MyExcelDataSourceTTT" data source does not exist:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</configSections>
<connectionStrings>
<add name="ExcelConnection" connectionString="Dsn=Excel Files;dbq=.\testdata.xlsx;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="MyExcelDataSource" connectionString="ExcelConnection" dataTableName="Sheet1$" dataAccessMethod="Sequential"/>
</dataSources>
</microsoft.visualstudio.testtools>
</configuration>
Now, when run the testing, you will get "Data source 'MyExcelDataSourceTTT' cannot be found in the test configuration settings.." error message.
I have defined lucene search index in sitecore 7.2 initial release. it's working fine but it did not updates itself on publish. although i have defined index updated both "OnPublishEndAsynchronousStrategy" & "RebuildAfterFullPublishStrategy" strategy as below.
<strategies hint="list:AddStrategy">
<strategy ref="contentSearch/indexUpdateStrategies/onPublishEndAsync" />
</strategies>
but it did not updates on publish a single item in smart publish.
I also have an alternative to rebuild index on publish from code
Sitecore.ContentSearch.ContentSearchManager.GetIndex("SearchIndexName").Rebuild();
but it's seems not a proper / efficient way to this.
Configuration code for reference:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<configuration type="Sitecore.ContentSearch.ContentSearchConfiguration, Sitecore.ContentSearch">
<indexes hint="list:AddIndex">
<index id="my_sitesearch_index" type="Sitecore.ContentSearch.LuceneProvider.LuceneIndex, Sitecore.ContentSearch.LuceneProvider">
<param desc="name">$(id)</param>
<param desc="folder">$(id)</param>
<param desc="propertyStore" ref="contentSearch/databasePropertyStore" param1="$(id)" />
<configuration ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration">
<indexAllFields>true</indexAllFields>
<include hint="list:IncludeTemplate">
<cmb>{FBAC6C1C-0B59-401A-B01A-8B7435EFA6A6}</cmb>
<home>{4291EDE0-8A5E-4B2E-A08F-D1299B262181}</home>
<category>{0D2CB285-CD2F-4813-A8F8-59E18507CD60}</category>
<externalLink>{77AD69A5-9F82-4955-B678-140EE6C8D5D8}</externalLink>
<fullwidthmap>{EFC1AD32-1495-46D8-B7BD-875B40D23CDE}</fullwidthmap>
<newsdetail>{BE9BD444-A1B7-43F0-98B1-61AF9A4CD83C}</newsdetail>
<product>{45E6DFFD-481E-40D4-923B-D5FD903EE44B}</product>
<productListing>{16E3C0EC-A5D7-49F3-B18E-AA0434DEAD3F}</productListing>
<segment>{99F070CF-7D8C-4F76-91B1-5B165DB7D7B4}</segment>
</include>
<fieldMap ref="contentSearch/indexConfigurations/defaultLuceneIndexConfiguration/fieldMap">
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="predictive_search_keywords" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
<analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
</field>
</fieldNames>
</fieldMap>
<include hint="list:IncludeField">
</include>
</configuration>
<strategies hint="list:AddStrategy">
<strategy ref="contentSearch/indexUpdateStrategies/onPublishEndAsync" />
</strategies>
<commitPolicyExecutor type="Sitecore.ContentSearch.CommitPolicyExecutor, Sitecore.ContentSearch">
<policies hint="list:AddCommitPolicy">
<policy type="Sitecore.ContentSearch.TimeIntervalCommitPolicy, Sitecore.ContentSearch" />
</policies>
</commitPolicyExecutor>
<locations hint="list:AddCrawler">
<crawler type="Sitecore.ContentSearch.SitecoreItemCrawler, Sitecore.ContentSearch">
<Database>web</Database>
<Root>/sitecore/content</Root>
</crawler>
</locations>
</index>
</indexes>
</configuration>
</contentSearch>
</sitecore>
</configuration>
Thanks,
I m trying to use the obfuscar free tool to protect my code from reverse engineering. I'm trying to obfuscate the provided example Basic Example. The problem that I can't find how to configure it.
Here's my config.xml
<configuration>
<startup><supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
<Obfuscator>
<Var name="InPath" value="C:\Users\user\Desktop\Obfuscar_2.0.0\Examples\BasicExample\BasicExampleExe\bin\Debug" />
<Var name="OutPath" value="C:\Users\user\Desktop\Obfuscar_2.0.0\Examples\BasicExample\BasicExampleExe\bin\Debug" />
<Module file="$(InPath)\BasicExampleExe.exe" />
<Module file="$(InPath)\BasicExampleLibrary.dll" />
<Var name="KeepPublicApi" value="true" />
<Var name="HidePrivateApi" value="true" />
</Obfuscator>
</configuration>
I had the same question... the example Release.proj build file they provide in the Git attempts to build the Obfuscar binary from scratch. So you need to change two lines of the Release.proj file, assuming you're going to be using the pre-compiled Obfuscar binary file.
First, change the path to the ObfuscarExe path to where you have the binary saved similar to this:
<!-- obfuscator bits -->
<PropertyGroup>
<ObfuscatorExe>C:\Program Files (x86)\Obfuscar\obfuscar.Console.exe</ObfuscatorExe>
<ObfuscatorProject>$(BasePath)\obfuscar.xml</ObfuscatorProject>
<ObfuscatorInput>$(BasePath)\Obfuscator_Input</ObfuscatorInput>
<ObfuscatorOutput>$(BasePath)\Obfuscator_Output</ObfuscatorOutput>
</PropertyGroup>
Second, comment out the command to compile the Obfuscar solution:
<ItemGroup>
<CompileSolution Include="$(BasePath)\BasicExample.sln" />
<!-- <CompileObfuscar Include="..\..\Obfuscar\Obfuscar.sln" /> -->
</ItemGroup>