VS2013 CodeCoverage.exe runsettings file never parses - c#

Environment: Visual Studio 2013 Premium, Win7Ultimate, CodeCoverage.exe
Goal: Code Coverage Report that excludes test project code to later be converted to a .coveragexml for reporting to SonarQube 5.1.
Annoyance I wouldn't even know of this parse error without adding the /verbose switch to the command. My only indication of a failure was the .coverage file was no longer being generated when I added the /config switch.
File Works in VS2013 IDE: MyProject.runsettings file provides the expected output using "Analyze Code Coverage" in the IDE.
Menu: Test | Test Settings | Select Test Settings File... MyProject.runsettings
Menu: Test | Analyze Code Coverage | All Tests
Attempting to run the CodeCoverage.exe file to generate code coverage for my tests I can't seem to use ANY *.runsettings files without getting an error:
"Error: Failed to parse configuration file <configfile>.runsettings"
Path Definitions:
codeCoveragePath = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools
vstestpath = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow
myProjectOutputPath = assume correct since I get results when not using /config switch
Run Command receiving Error (assume paths are correct):
Note: I'm not showing with /verbose switch since I shouldn't be using it under working conditions
%codeCoveragePath%\CodeCoverage.exe collect /config:MyProject.runsettings /output:CoverageOutput.coverage %vstestpath%\vstest.console.exe %myProjectOutputPath%\MyClass.Tests.Unit.dll
Exe Works if I DON'T use the /config option If I remove the /config:MyProject.runsettings from the run command, I get a full report that includes the test project, but that let's me know the rest of the command is correct, it just doesn't like the runsettings file.
I've tried using the following examples:
Visual Studio 2013 runsettings Template file WITHOUT modification
MSDN's sample file
Completed blank file, no content: error
File with only the xml declaration: error
File with only RunSettings Node declared: error
I've even used the Troubleshooting tips from MSDN, too: no help.
MyProject.runsettings file:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<DataCollectionRunSettings>
<DataCollectors>
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*\.Tests\.Unit\.dll$</ModulePath>
</Exclude>
</ModulePaths>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</DataCollectionRunSettings>
</RunSettings>
The file seems to be correct based on the fact that the IDE will use it and generate the correct output in the "Code Coverage Results" window by only reporting the MyClass code and not any MyClass.Tests.Unit code.
I'm at the point that I think it is the CodeCoverage.exe command line doesn't like the /config option or it is using a different xml schema.
Update
Works gives the output I want, just can't specify file location for next step
%vstestpath%\vstest.console.exe /Settings:MySettings.runsettings %myProjectOutputPath%\MyClass.Tests.Unit.dll
Doesn't Work Gives exact opposite output I want (only test.dll coverage in the report).
%codeCoveragePath%\CodeCoverage.exe collect /output:CoverageOutput.coverage %vstestpath%\vstest.console.exe /Settings:MySettings.runsettings %myProjectOutputPath%\MyClass.Tests.Unit.dll
Still looking for an answer.

I believe you need to specify the runsettings file at the back of the vstest.console.exe using the /Settings: flag (as opposed to the config flag of the CodeCoverage.exe).
So that your command becomes:
%codeCoveragePath%\CodeCoverage.exe collect
/output:CoverageOutput.coverage %vstestpath%\vstest.console.exe
%myProjectOutputPath%\MyClass.Tests.Unit.dll
/Settings:MyProject.runsettings

I was having the same problem and found your question when searching for some info on my error. My assumption had been also that the config file format was the same as the .runsettings used by vstest.console.exe but from the parse error after adding /verbose I then suspected it was a different format so had a look to see if there was a default config for CodeCoverage.exe to see what it looked like, and I did find one at:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.config
And the format appears to just be the inner <CodeCoverage> part of the .runsettings format
I have now got filtering to work but needed to copy over all the filter items from the default config as they now don't get loaded, so I ended up using a config like the following:
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>.*\\unittests.dll</ModulePath>
</Exclude>
</ModulePaths>
<Sources>
<Exclude>
<!--extracted from default CodeCoverage.config -->
<Source>.*\\atlmfc\\.*</Source>
<Source>.*\\vctools\\.*</Source>
<Source>.*\\public\\sdk\\.*</Source>
<Source>.*\\externalapis\\.*</Source>
<Source>.*\\microsoft sdks\\.*</Source>
<Source>.*\\vc\\include\\.*</Source>
</Exclude>
</Sources>
<Functions>
<Exclude>
<!--extracted from default CodeCoverage.config -->
<Function>^std::.*</Function>
<Function>^ATL::.*</Function>
<Function>.*::__GetTestMethodInfo.*</Function>
<Function>.*__CxxPureMSILEntry.*</Function>
<Function>^Microsoft::VisualStudio::CppCodeCoverageFramework::.*</Function>
<Function>^Microsoft::VisualStudio::CppUnitTestFramework::.*</Function>
<Function>.*::YOU_CAN_ONLY_DESIGNATE_ONE_.*</Function>
</Exclude>
</Functions>
</CodeCoverage>
and command line:
CodeCoverage collect /output:coverage.dat /config:coverage.settings vstest.console unitTests.dll /Logger:trx /Settings:test.runsettings

Okay, Here comes the HACK!!!!
Basic steps:
Find and delete all *.coverage files
Run vstest command WITHOUT [codecoverage.exe collect] wrapper
Find the new *.coverage files and send to [codecoverage.exe analyze] command
Details
I updated the build.proj file I've been using to execute all this to do the Basic steps:
<PropertyGroup>
<SqCodeCoverageResultsFile>VisualStudio.coveragexml</SqCodeCoverageResultsFile>
</PropertyGroup>
<Target Name="BuildTestAssemblyList"
BeforeTargets="RunAllTestsWithCodeCoverageAndConvertToXmlOutput">
<CreateItem Include="**\*.Tests.Unit.dll">
<Output TaskParameter="Include" ItemName="TestAssemblies" />
</CreateItem>
</Target>
<Target Name="BuildCoverageFileList"
BeforeTargets="RunAllTestsWithCodeCoverageAndConvertToXmlOutput">
<CreateItem Include="**\*.coverage">
<Output TaskParameter="Include" ItemName="CoverageFiles" />
</CreateItem>
</Target>
<Target Name="RunAllTestsWithCodeCoverageAndConvertToXmlOutput">
<Delete Condition="Exists($(SqCodeCoverageResultsFile))" Files="$(SqCodeCoverageResultsFile)" />
<Delete Files="#(CoverageFiles)" />
<Exec Command=""$(VsTestExecutable)" /EnableCodeCoverage /Settings:MyProject.runsettings /inIsolation /logger:trx #(TestAssemblies->'"%(FullPath)"',' ') " />
<CreateItem Include="**\*.coverage">
<Output TaskParameter="Include" ItemName="NewCoverageFiles" />
</CreateItem>
<Exec Command=""$(VsCodeCoverageExecutable)" analyze /output:"$(SqCodeCoverageResultsFile)" #(NewCoverageFiles->'"%(FullPath)"',' ') " />
</Target>`
Now running the CodeCoverage.exe analyze command with those found *.coverage files will now output to the same filename I was trying to achieve before and get the results I wanted.
MSBuild.SonarQube.Runner.exe gets what it wants, I have the results I want, and the world can start to revolve again =)
Improvement: I could use a CustomTask and search for the perfect or most recent or whatever logic you can think of for that correct single file so I wouldn't have to delete all my other *.coverage files. I could, but I didn't because this is supposed to be run on a build server that shouldn't have that kind of history laying around anyways in my opinion.

Related

Running java.exe as pre-build step in .NET Core/Standard fails with 9009

I am trying to run java.exe as a pre-build step in a C#-.NET Standard 2.0 project. The csproj file contains the following snippet:
<Target Name="Java" BeforeTargets="Build">
<Exec Command="c:\Windows\System32\java.exe"/>
</Target>
(I simplified the command line for testing.) The file java.exe exists in c:\windows\system32, but the build fails with error code 9009:
c:\Windows\System32\java.exe' is not recognized as an internal or external command,
1>operable program or batch file.
1>C:\workspace\Test.csproj(21,5): error MSB3073: The command "c:\Windows\System32\java.exe" exited with code 9009.
1>Done building project "Test.csproj" -- FAILED.
Running java.exe directly from the command line works fine.
Apparently, c:\windows\system32 is routed to another path because Visual Studio is a 32 bit application. Using the special alias "Sysnative" works:
<Target Name="Java" BeforeTargets="Build">
<Exec Command="c:\Windows\Sysnative\java.exe"/>
</Target>
More information here.

Code is missing for service MyServicePkg

I am attempting to upgrade my application like so:
It fails with the following error:
Error details:
2>Test-ServiceFabricApplicationPackage : The BuildLayout of the application in
2>C:\Users\me\AppData\Local\Temp\TestApplicationPackage_2205895293421\4myc2vpp.bdq\Debug is invalid. Code is
2>missing for service MyServicePkg.
2>At C:\Program Files\Microsoft SDKs\Service
2>Fabric\Tools\PSModule\ServiceFabricSDK\Publish-UpgradedServiceFabricApplication.ps1:135 char:38
2>+ ... nSuccess = (Test-ServiceFabricApplicationPackage $AppPkgPathToUse -Im ...
2>+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2> + CategoryInfo : InvalidOperation: (:) [Test-ServiceFabricApplicationPackage], FabricImageBuilderValidati
2> onException
2> + FullyQualifiedErrorId : TestApplicationPackageErrorId,Microsoft.ServiceFabric.Powershell.TestApplicationPackage
2>
2>Finished executing script 'Deploy-FabricApplication.ps1'.
2>Time elapsed: 00:00:40.4035177
2>The PowerShell script failed to execute.
========== Build: 1 succeeded, 0 failed, 46 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
Here are my properties for that specific project:
What am I doing wrong? What does this exception mean?
I would go with Hans Passant's comment:
The most basic mishap is that the name you used in the
ServiceManifest.xml file does not match the name of the .exe that your
project generates
It is also visible in your debug output as the build succeeded but the publish failed.
========== Build: 1 succeeded, 0 failed, 46 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
It can happen in a number of ways and most probably due to renaming of the project or renaming of the Assembly Name. If you rename the project or the Assembly Name of your project, your build executable will be according to that name. Consider the following case.
I renamed the Assembly Name from "MyService" to "MyRenamedService". So the build executable will be MyRenamedService.exe. So you have to set this in your ServiceManifest.xml.
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>MyRenamedService.exe</Program>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
</CodePackage>
The best way to be sure of the build executable path is to build the solution. It will show the full path of the executable in Output window.
1>------ Build started: Project: Web1, Configuration: Debug Any CPU ------
1>Web1 -> C:\.....\Application2\Web1\bin\Debug\net461\win7-x64\MyRenamedService.exe
2>------ Build started: Project: Application2, Configuration: Debug x64 ------
========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
Here Web1 is the Project Name I started with, MyRenamedService.exe is the build executable name (because I renamed the Assembly Name), it should be set in the ServiceManifest.xml as shown above.
At a higher level, this error happens when the folder named "Code" is missing under the ServiceFabric Project Folder during Publish (after build shows as successfully completed).
Build is the culprit here, not Publish, as Publish is expected to look for assets under
Folder Path: {{SFProjectFolder}}\pkg\Release\{{ServiceName}}
Please note that the {{ServiceName}} and "Code" is taken from the ServiceManifest.xml of the corresponding project referenced in the SF application.
ServiceManifest.xml
<ServiceManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="{{ServiceName}}" Version="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<ServiceTypes>
<StatelessServiceType ServiceTypeName="{{ServiceType}}" />
</ServiceTypes>
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>{{ServiceName}}.exe</Program>
</ExeHost>
</EntryPoint>
</CodePackage>
<ConfigPackage
What caused the issue:
From other answers, it looks like the Build not copying the compiled assets into the right path/folder, could happen due to multiple issues.
In our case, we had changed the Configuration Manager settings for Release Configuration from AnyCPU to x64 and deleted the AnyCPU Platform setting from the solution. And for some reason, the Services.csproj still had the AnyCPU Platform setting. We ended up having the build showing as successful, but "Code" folder not being generated under Release folder.
Fix:
To fix this, we had to manually edit the .csproj and remove the PropertyGroup sections that still used "AnyCPU" like the one below:
PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "
After this change, Build correctly placed the contents in the right path and Publish worked as expected.
This issue occurs when your service's executable .exe path is wrong in ServiceManifest.xml.
<CodePackage> contains .exe path in <Program> just check it out first:
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>MyServicePkgHost.exe</Program> // Important
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</EntryPoint>
</CodePackage>
Important References:
Code is missing for service error Service Fabric
https://stackoverflow.com/a/47291969/5377037
https://stackoverflow.com/a/48729871/5377037
For confirming you are not missing anything look at below two tutorials:
Service Fabric application upgrade tutorial using Visual Studio
Service Fabric application upgrade using PowerShell
Edit 1:-
Your package layout of application directory structure should be:
PS D:\temp> tree /f .\MyServicePkg
D:\TEMP\MYSERVICEPKG
│ ApplicationManifest.xml
│
└───MyServicePkgManifest
│ ServiceManifest.xml
│
├───MyServicePkg
│ MyServicePkgHost.exe
│
├───MyServicePkgConfig
│ Settings.xml
│
└───MyServicePkgData
init.dat
Error:
Why the "Code is missing for service package" occurs?
Reason:
In above directory there is missing a .bat code file from you application directory:
│
├───MyServicePkg
│ MyServicePkgHost.exe
│ MyServicePkgSetup.bat
|
So you have to add that missing file MyServicePkgSetup.bat. And following is a simple service manifest ServiceManifest.xml example that shows the SetupEntryPoint and the main EntryPoint for the service.
<?xml version="1.0" encoding="utf-8" ?>
<ServiceManifest Name="MyServiceManifest" Version="SvcManifestVersion1" xmlns="http://schemas.microsoft.com/2011/01/fabric" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Description>An example service manifest</Description>
<ServiceTypes>
<StatelessServiceType ServiceTypeName="MyServiceType" />
</ServiceTypes>
<CodePackage Name="Code" Version="1.0.0">
<SetupEntryPoint>
<ExeHost>
<Program>MyServicePkgSetup.bat</Program> // important
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</SetupEntryPoint>
<EntryPoint>
<ExeHost>
<Program>MyServicePkgHost.exe</Program> // important
</ExeHost>
</EntryPoint>
</CodePackage>
<ConfigPackage Name="Config" Version="1.0.0" />
</ServiceManifest>
Configure the policy by using a local account
After you configure the service to have a setup entry point, you can change the security permissions that it runs under in the application manifest:
Under the <ServiceManifestImport> section, configure a policy to apply this principal to <SetupEntryPoint>. This tells Service Fabric that when the MyServicePkgSetup.bat file is run, it should be RunAs with administrator privileges. Given that you have not applied a policy to the main entry point, the code in MyServicePkgHost.exe runs under the system NetworkService account. This is the default account that all service entry points are run as.
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ApplicationTypeName="MyApplicationType" ApplicationTypeVersion="1.0.0" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="MyServiceTypePkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
<Policies>
<RunAsPolicy CodePackageRef="Code" UserRef="SetupAdminUser" EntryPointType="Setup" />
</Policies>
</ServiceManifestImport>
<Principals>
<Users>
<User Name="SetupAdminUser">
<MemberOf>
<SystemGroup Name="Administrators" />
</MemberOf>
</User>
</Users>
</Principals>
</ApplicationManifest>
PS: You can verify the package structure locally through PowerShell by using the Test-ServiceFabricApplicationPackage command.
Workaround to add missing file MyServicePkgSetup.bat:
Let's now add the file MyServicePkgSetup.bat to the Visual Studio project to test the administrator privileges. In Visual Studio, right-click the service project and add a new file called MyServicePkgSetup.bat.
Next, ensure that the MyServicePkgSetup.bat file is included in the service package. By default, it is not. Select the file, right-click to get the context menu, and choose Properties. In the Properties dialog box, ensure that Copy to Output Directory is set to Copy if newer. See the following screenshot:
**File Path: ** C:\..\YourApplication\
Now open the MyServicePkgSetup.bat file and add the following commands:
REM Set a system environment variable. This requires administrator privilege
setx -m TestVariable "MyValue"
echo System TestVariable set to > out.txt
echo %TestVariable% >> out.txt
REM To delete this system variable us
REM REG delete "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v TestVariable /f
Next, build and deploy the solution to a local development cluster. After the service has started, as shown in Service Fabric Explorer, you can see that the MySetup.bat file was successful in a two ways. Open a PowerShell command prompt and type:
PS C:\ [Environment]::GetEnvironmentVariable("TestVariable","Machine")
MyValue
Then, note the name of the node where the service was deployed and started in Service Fabric Explorer--for example, Node 2. Next, navigate to the application instance work folder to find the out.txt file that shows the value of TestVariable. For example, if this service was deployed to Node 2, then you can go to this path for the MyApplicationType:
C:\SfDevCluster\Data\_App\Node.2\MyApplicationType_App\work\out.txt

VSTS/TFS set environment variable ASP.NET core

I'm trying to deploy an ASP.NET Core application to IIS using VSTS with the following tasks
However, after much googling and browsing through MS docs I couldn't find a way to set environment variables for the deployment. The variables I set in the release definition in environment scope aren't getting set as environment variables.
Any idea how to achieve that?
The environment variables you set in VSTS are just used for the deployment itself (ie anything that VSTS is doing such as building your application or running unit tests), but the runtime application will use whichever ones are on the server hosting it.
You will need to set the environment variables on the IIS server that VSTS is deploying to if you want your deployed application to use them as well. Microsoft docs show how to set this depending on your server: Setting the environment
Update in response to comments:
The reccommended way to set environment variables is on the machine itself - ie. log in to the IIS server you are deploying to and add the ASPNETCORE_ENVIRONMENT environment variable there in system properties -> advanced settings -> environment variables
If for some reason you aren't able to do this, you can set them in the Web.config file (according to that documentation). If you are always setting the same value you should be able to just put what you need in the Web.config like so
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
If you really need the XML transforms (which, honestly, I'm not sure you do in this situation - this is for altering the Web.config file at deployment time based on the build configuration. As somebody else mentioned, with asp.net core the reccommended config setup is appsettings[.environment].json files which are automagically loaded based on the matching machine level ASPNETCORE_ENVIRONMENT env variable), you need to actually define the transformations in a transform file using the correct syntax and have it replace the parts you want to change. This is obviously the more difficult option.
See: How to: Transform Web.config When Deploying a Web Application Project for creating the transformation files and Web.config Transformation Syntax for Web Project Deployment Using Visual Studio for the configuration syntax if you choose to go down that path
Something like this (unable to currently test but this should give you an idea - note the transform namespace on the transform file and the xdt: attributes). I believe the transform file that gets loaded matches the build configuration which you may need to configure as part of the VSTS task:
Web.config
<configuration>
<system.webServer>
<aspNetCore ...>
<environmentVariables>
<environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
Web.Release.config (transform file for build configuration "Release")
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<aspNetCore ...>
<environmentVariables>
<environmentVariable xdt:Transform="Replace" xdt:Locator="Match(name)" name="ASPNETCORE_ENVIRONMENT" value="Production" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
For ASP.NET Core 1.x projects with a web.config you can use the below.
Since your deployment has a "Dev" environment, commit to your project the following config file:
web.Dev.config
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0" xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<aspNetCore>
<environmentVariables xdt:Transform="InsertIfMissing" />
<environmentVariables>
<environmentVariable xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" name="ASPNETCORE_ENVIRONMENT" />
<environmentVariable xdt:Transform="Replace" xdt:Locator="Match(name)" name="ASPNETCORE_ENVIRONMENT" value="Development" />
</environmentVariables>
</aspNetCore>
</system.webServer>
</configuration>
The above will create the environmentVariables section in your web.config if it does not already exist.
Replace "Dev" in web.Dev.config with other environment names as necessary.
ASPNETCORE_ENVIRONMENT used as an example above, change for other
variables.
Remove the xmlns="" attribute from the configuration element above if your web.config does not have the same namespace attribute on the configuration element.
In your project.json, add under publishOptions => include:
"web.dev.config"
In VSTS deployment make sure to check "XML transformation" under the IIS Web App Deploy task:
Here is the powershell script I use within Release pipeline (I don't like setting ASPNETCORE_ENVIRONMENT within the build)
arguments:
-p $(System.DefaultWorkingDirectory)\$(Build.DefinitionName)\drop\testbld-Test\web.config -e Development
Inline Script:
param ([string]$p,[string]$e)
$doc = new-object System.Xml.XmlDocument
$location = "$p"
$doc.Load($location)
$subNode = $doc.CreateElement("environmentVariable")
$node = $doc.CreateElement("environmentVariables")
$doc.SelectSingleNode("//aspNetCore").AppendChild($node)
$doc.SelectSingleNode("//environmentVariables").AppendChild($subNode)
foreach($nd in $subNode) {$nd.SetAttribute("name", "ASPNETCORE_ENVIRONMENT");$nd.SetAttribute("value", "$e");}
$doc.Save($location)
I add it as an argument during the "Publish" step of the build:
/p:EnvironmentName=Development
Then it will be added to the web.config of the build output.
Refer to these steps below:
Set config files properties (e.g. web.config, web.QA.config), Copy to Output Directory: Copy if newer)
.NET Core task (Command: restore)
.NET Core task (command: build)
.NET Core task (Command: publish; Check Publish Web Projects option; Arguments: --configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory); Check Zip Published Projects option)
Publish Build Artifacts (Path to publish:$(build.artifactstagingdirectory))
Open release definition, change environment name (e.g. QA, match the config file name)
IIS Web Deploy task: (Package or Folder: $(System.DefaultWorkingDirectory)\**\*.zip; Check XML transformation option (it is based on Environment name to look for transform source file)
Then the web.[environmentname].config file (e.g. web.QA.config) will be transformed to web.config file.
You also can do it through XDT transform task, (the files can’t be in the zip file, so un-check Zip Published Projects option: step4, and archive files through Archive Files task in release)
Another approach to setting environment variables (other than using the XML transform approach) is to add a Powershell task which uses appCmd command to set environment variables in the ApplicationPool scope
C:\Windows\system32\inetsrv\appcmd.exe set config -section:system.applicationHost/applicationPools /+"[name='XyzPool'].environmentVariables.[name='ASPNETCORE_ENVIRONMENT',value='Dev']" /commit:apphost

Getting error candle.exe : error CNDL0103 : The system cannot find the file 'Product.wxs' with type 'Source'

I am using the latest version of wix v3.10.3 and while executing the following command:
D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC>call "C:\Program Files (x86)\WiX Toolset v3.10\bin\candle.exe" -sw1076 -sw1072 -dDebug -d"ADX_PATH=C:\Program Files (x86)\Add-in Express\Add-in Express .NET for Internet Explorer\\" -d"DevEnvDir=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\\" -d"SolutionDir=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\\" -dSolutionExt=.sln -dSolutionFileName=PMP.sln -dSolutionName=PMP -d"SolutionPath=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\PMP.sln" -dConfiguration=Release -dOutDir=bin\Release\ -dPlatform=x86 -d"ProjectDir=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\PMPSetup\1.0.0\\" -dProjectExt=.wixproj -d"ProjectFileName=PMPSetup(1.0.0).wixproj" -d"ProjectName=PMPSetup(1.0.0)" -d"ProjectPath=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\PMPSetup\1.0.0\PMPSetup(1.0.0).wixproj" -d"TargetDir=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\PMPSetup\1.0.0\bin\Release\\" -dTargetExt=.msi -d"TargetFileName=PMPSetup(1.0.0).msi" -d"TargetName=PMPSetup(1.0.0)" -d"TargetPath=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\PMPSetup\1.0.0\bin\Release\PMPSetup(1.0.0).msi" -dPMP.Configuration=Release -d"PMP.FullConfiguration=Release|AnyCPU" -dPMP.Platform=AnyCPU -d"PMP.ProjectDir=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\\" -dPMP.ProjectExt=.csproj -dPMP.ProjectFileName=PMP.csproj -dPMP.ProjectName=PMP -d"PMP.ProjectPath=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\PMP.csproj" -d"PMP.TargetDir=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\bin\Release\\" -dPMP.TargetExt=.dll -dPMP.TargetFileName=PMP.dll -dPMP.TargetName=PMP -d"PMP.TargetPath=D:\File_Transfer\11-Nov-16\internetexplorer\2000\INTERNET_EXPLORER_SRC\PMP\bin\Release\PMP.dll" -out obj\\Release\ -arch x86 -ext "C:\Program Files (x86)\WiX Toolset v3.10\bin\\WixNetFxExtension.dll" Product.wxs StandardUI.wxs
I get the following error:
candle.exe : error CNDL0103 : The system cannot find the file 'Product.wxs' with type 'Source'.
When I compile using Visual Studio, I don't get any error and the build succeeded. Whereas via command prompt, I'm getting the above error.
Can anyone suggest how to resolve this?
candle.exe seems to have trouble parsing quoted command line arguments ending with a backslash. For example, change this:
-d"ADX_PATH=C:\Program Files (x86)\Add-in Express\Add-in Express .NET for Internet Explorer\\"
to:
-d"ADX_PATH=C:\Program Files (x86)\Add-in Express\Add-in Express .NET for Internet Explorer"
The same issue exists in multiple places in the command you provided.
I'm using macros like this:
-d"BinariesDir=$(OutputPath)"
which I had to change to:
-d"BinariesDir=$(OutputPath)."
so that when they are expanded, they don't end in a \.
Run your batch file from the same folder where your Product.wxs and Product.wixobj files are.
Let's name your batch file as installer.bat
Edit your installer.bat with:
candle Product.wxs
light Product.wixobj
#pause
Copy your installer.bat file in the setupproject folder where your Product.wxs file is and other bin and obj folders are.
Run the installer.bat file.
Hope that works for u.
Thank you
I found the same error when I did not pass BOTH extension dll's like this:
-ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\\WixUtilExtension.dll"
-ext "C:\Program Files (x86)\WiX Toolset v3.11\bin\\WixUIExtension.dll"
This might be you are referring some fragment in product.wxs which is empty.
Like
in product.wxs
!--<Feature Id="F_UpdateConnectionString" Title="Updating ConnectionString" Description="Update the Connection String" Level="1">
<ComponentRef Id="SetConfigurationValues" />
</Feature>-->
and insidefragment
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="SetConfigurationValues" Guid="03D1E734-464F-4A2D-B385-
42DECB86C557">
</Component>
</DirectoryRef>
</Fragment>
here we can see Component must have something to build successfully.

How to get SpecUnit to run within a TeamCity CI build

I am trying to get SpecUnit to run in a continuous integration build using Nant. At the moment the files are in the correct place but no output is generated from SpecUnit.Report.exe. Here is the relevant task from the nant build script:
<echo message="**** Starting SpecUnit report generation ****" />
<copy file="${specunit.exe}" tofile="${output.dir}SpecUnit.Report.exe" />
<exec program="${output.dir}SpecUnit.Report.exe" failonerror="false">
<arg value="${acceptance.tests.assembly}" />
</exec>
Please note:
${specunit.exe} is the full path to where “SpecUnit.Report.exe” is located.
${output.dir} is the teamcity output directory for the current build agent.
${acceptance.tests.assembly} is "AcceptanceTests.dll"
Anyone tried this before?
You need to specify the full path to the assembly argument I think...
<exec program="${output.dir}SpecUnit.Report.exe" verbose="true">
<arg value="${output.dir}${acceptance.tests.assembly}" />
</exec>

Categories

Resources