FAKE error fails in MS.NET build but not Mono - mono

I've got CI builds set up for my project that use MS .Net (with AppVeyor) and Mono (with Travis CI).
The current build has a problem in that it tries to run an executable which is missing. This fails the AppVeyor build:
Starting Target: Run Unit Tests (==> BuildUnitTests, BuildIntegrationTests, BuildSampleApplication)
Running build failed.
Error:
System.Exception: Start of process HttpClient.UnitTests/bin/Release\HttpClient.UnitTests.exe failed. The system cannot find the file specified
at Fake.ProcessHelper.directExec#218.Invoke(String message) in C:\code\fake\src\app\FakeLib\ProcessHelper.fs:line 218
at Fake.ProcessHelper.directExec(FSharpFunc`2 configProcessStartInfoF) in C:\code\fake\src\app\FakeLib\ProcessHelper.fs:line 213
at FSI_0001.Build.clo#68-3.Invoke(Unit _arg3) in C:\projects\http-fs\build.fsx:line 71
at Fake.TargetHelper.runSingleTarget(TargetTemplate`1 target) in C:\code\fake\src\app\FakeLib\TargetHelper.fs:line 411
But the Travis build just carries on regardless, apparently not getting an exception:
Starting Target: Run Unit Tests (==> BuildUnitTests, BuildIntegrationTests, BuildSampleApplication)
Cannot open assembly 'HttpClient.UnitTests/bin/Release/HttpClient.UnitTests.exe': No such file or directory.
Finished Target: Run Unit Tests
(see https://travis-ci.org/relentless/Http.fs/builds/57475713)
This is the code that fails (or not):
ProcessHelper.directExec (fun procInfo ->
procInfo.FileName <- Path.Combine(unitTestsDir, "bin/Release", "HttpClient.UnitTests.exe")
) |> ignore
Any idea why this difference exists, and more importantly how to make it the same on Mono? (In this situation, I'd really like the build to fail). Of course, in this case I could check for the file's existence, but ideally I want the build to fail on any problem.
Edit
The problem, specifically, is that the build does not fail under Mono when I think it should. It seems that the exception which is raised on MS .NET due to the missing exe is either not raised or swallowed on Mono, resulting in a build which passes when it should (IMO) fail.

Looks to me like the file ends up in bin/Debug, not bin/Release.
On line 1244 in the build output you have:
Copying file from '/home/travis/build/relentless/Http.fs/HttpClient.UnitTests/obj/Release/HttpClient.UnitTests.exe' to '/home/travis/build/relentless/Http.fs/HttpClient.UnitTests/bin/Debug/HttpClient.UnitTests.exe'

Related

Dll lookup fails on application load time

I'm trying to follow bevy's tutorial and setup everything on Windows 10 (21H1) x64. The setup kinda works. I did the following build optimizations (from bevy's tutorial):
bevy's dynamic link feature
switch to the LLD linker
switch to latest rust nightly
disable shared generics (because of this issue)
My cargo.toml
[package]
name = "foo"
version = "0.1.0"
authors = ["foo <foo#bar.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = "0.5"
My main.rs (the only code file so far):
use bevy::prelude::*;
fn main() {
println!("hello");
App::build().run();
}
My .cargo/config.toml:
[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
rustflags = ["-Zshare-generics=off"]
After building my application, target/debug/ looks something like this (I removed some entries):
deps/
bevy_dylib.dll
bevy_dylib.dll.lib
bevy_dylib.pdb
foo.d
foo.exe
foo.pdb
I can build and run the application just fine using cargo with the command cargo run --features bevy/dynamic. The program prints "hello" and exists normally. However, if I run the program from the terminal (powershell in my case) nothing is print and the program exists with no error code. Seeing that lldb also crashes with "unknown error" I went ahead and took a closer look with procmon.
cargo run vs .\foo.exe
Using cargo run --features bevy/dynamic works fine, but .\foo.exe (run directly from powershell) fails without errors. Procmon reveals that .\foo.exe tries to load a different dll, it searches for bevy_dylib-d54840081e5b3869.dll instead of bevy_dylib.dll. This obviously fails because this file doesn't exist and so the program terminates before it even reaches main().
But why does cargo run --features bevy/dynamic work then? Well it turns out that the program still tries to load bevy_dylib-d54840081e5b3869.dll, however this time the loader looks up different paths. There is an additional search path: {my_project}/target/debug/deps/. And that directory actually has a dll with that exact name which is then loaded and the program can execute normally. So it turns out we never even try to use the dll target/debug/bevy_dylib.dll which makes me wonder why it's there in the first place.
My questions are:
Why does cargo run use additional lookup directories at load time linking?
Why does the program search for bevy_dylib-d54840081e5b3869.dll instead of bevy_dylib.dll?
Is this fixable without some nasty post build tasks that copy dlls manually around?

SonarQube 5.6 - MSBuild Fakes Generation failing (SonarQube.Integration.targets)

I posted a similar question here.
Unfortunately, this issue is coming up again after having upgraded our build machines to run on Visual Studio Online 2015's Build and Release Manager.
This is the error that I get from a solution that generates Fakes assemblies used in unit testing:
D:\builds\TFS2015agent_2_work\1\.sonarqube\bin\targets\SonarQube.Integration.targets(240,5):
error MSB3491: Could not write lines to file "D:\builds\TFS2015agent_2_work\1\.sonarqube\out\\f_AnyCPU_Release_9840\FilesToAnalyze.txt".
The process cannot access the file 'D:\builds\TFS2015agent_2_work\1\.sonarqube\out\f_AnyCPU_Release_9840\FilesToAnalyze.txt' because it is being used by another process. [D:\builds\TFS2015agent_2_work\1\s\FakesFilePath\f.csproj] [D:\builds\TFS2015agent_2_work\1\s\FakesFileProj]
2016-09-13T20:01:37.6477261Z GENERATEFAKES : error : project compilation failed with exit code 1 [D:\builds\TFS2015agent_2_work\1\s\FakesFilePath\]
Does anyone have an idea of why this is happening? What process is causing the error? Could it possibly be related to the fakes compiling while SonarQube tries to access it?

Unable to run a test from MTM - Config issue

I have set up a Test Controller and Test Agent running in separate machines and they are able to communicate with each other.
When I try to run the test from MTM (Selenium Tests), the test failed with the below error message
(QTController.exe, PID 1104, Thread 15) Could not use lab service account to access the build directory.
Failure: Network path does not exist or is not accesible using following user:
https://mydevelopment.visualstudio.com/defaultcollection/c2f372df-8c45-487a-9b51-4ced6e8f6037/_apis/build/builds/969/artifacts?artifactName=drop&%24format=zip
using MYDEV\timothy.alex. Error Code: 67
(QTController.exe, PID 1104, Thread 15) TcmRunner: Error starting the test run: The build directory of the test run either does not exist or access permission is required..
This clearly mentions that the error is because of access issue. But when I try downloading the build from the url mentioned in the error log using the same credentials mentioned in the ERROR log, I am able to download the drop zip file.
Is there any thing I am missing in the set up. Any help would be really really great.
It looks like you're using the new task-based build system. You can't run automated tests from a task-based build from MTM at present -- you have to use the older XAML build system for that.

nHibernate not creating Oracle driver in MSTests run on command line

I've been working on this particular issue for a couple weeks now, and I'm exceedingly frustrated. As such, I'll give all the information I can and hope for the best.
My team is working on building a new application. Here's the alphabet soup:
.Net 4.5.1
nHibernate 4.0.0.4000 with FluentNHibernate 2.0.3.0
Oracle 11g (Oracle.DataAccess 2.112.1.0, which has Copy Local set to true)
Visual Studio 2013 is the IDE
Windows 7 Professional
I am compiling the application as a 32-bit app, and I have confirmed that I have the 32bit version of Oracle installed.
We've written some tests for the NHibernate mappings, which we run through MSTest. When we run these through Visual Studio's test explorer, they all run properly and pass. The application itself also properly compiles and deploys as it should. We've verified the tests are running properly by checking the database between steps, so we're fairly sure that the tests themselves aren't the problem.
When we run MSTest through the command line though, we receive the following error:
Initialization method MyTests.Setup threw exception. NHibernate.HibernateException: NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.OracleDataClientDriver. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed..
I've tried reinstalling Oracle to no effect. I've tried checking the machine.config file for errors (as suggested in other posts here on SO) and found none.
Our Fluent configuration is as follows:
OracleDataClientConfiguration.Oracle10
.ConnectionString(connectionString)
.Driver("NHibernate.Driver.OracleDataClientDriver")
.ShowSql()
.FormatSql();
The code I'm running on the command line is the following:
(cd to the directory where the test .dll is)
>"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\MSTest.exe" /testcontainer:MyTests.dll /test:UnitTests
I feel like I'm missing something here. Any ideas?
Update: Solution Found
So here's a weird one. I followed Fran's solution below and installed the Oracle.ManagedDataAccess package and changed the NHibernate driver in our configuration above to NHibernate.Driver.OracleManagedDataClientDriver. As per our quick comment-discussion, this lead to a new error:
Initialization method MyTests.Setup threw exception. NHibernate.HibernateException: NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.OracleManagedDataClientDriver. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Configuration.ConfigurationErrorsException: Failed to find or load the registered .Net Framework Data Provider
Fran then lead me to another SO question which encouraged me to check the Oracle configuration piece by piece. What better way to do this than create a test?
var x = new OracleConnection(connectionString);
x.Open();
Assert.IsTrue(x.State == System.Data.ConnectionState.Open);
x.Close();
Assert.IsFalse(x.State == System.Data.ConnectionState.Open);
In my quick attempt to run this test, I ran the whole collection of UnitTests with the script I'd mentioned above. Low and behold, every test passes!
Doing my due diligence, try the following
I comment out that test, clean, rebuild, and run the script again. Failures.
I return to the old Oracle driver and add that new test in. Clean, Rebuild, Run. Failures.
Add back the new Oracle driver, make sure the new test is still in. Run tests OTHER than the new test. Passes.
For some reason, the combination of the new driver and explicitly referencing it in a test seems to have resolved the issue. I'm open for any theories as to why, but I bet that qualifies as a new question.
I would stop using the bit specific version of the oracle drivers and move to the managed driver (https://www.nuget.org/packages/Oracle.ManagedDataAccess/). It is bit agnostic, and doesn't require you to install the Oracle client at all.
I actually found the solution to the problem, and it all has to do with how the Oracle.DataAccess.dll file gets loaded at runtime (Disclosure: I work with wadeb on the same project).
It seems that Oracle.DataAccess.dll was being searched for in every location on the server except the build output folder in the Jenkins workspace, and as such was pulling the DLL file from the GAC.
One of the file paths used to find the DLL file is the folder in which the "current executable" is located. In our case, the "current executable" was mstest.exe. Copying the Oracle.DataAccess.dll file to C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE did the trick.
Did it work. Yes.
Was it a hack? Absolutely -- but now it works without having to upgrade to the managed Oracle drivers.
Our servers weren't using an Oracle client that worked with the managed driver, and it wasn't acceptable to have a broken continuous integration build until servers get upgraded.
I have got just the same error and I switched my tests to x64 and it works like a charm now:

help building castle dynamic proxy

So I pulled the source from https://svn.castleproject.org/svn/castle/DynamicProxy/trunk/
Open it up in vs.net 2008
problems:
vs.net can't open the assembly.cs
assembly signing failed
What am I doing, rather NOT doing?
Update
So I downloaded nant, setup the .bat file in my PATH so it works in cmd prompt.
I ran:
nant default.build
Getting this error:
build failed, \buildscripts\common-project.xml (48,3)
invalid element . Unknown task or datatype.
How exactly do I build the dynamicProxy project now?
update
This is what I did, see screenshot:
oh and my nant is:
#echo off
"E:\dev\tools\nant-bin\nant-0.86-nightly-2009-05-05\bin\Nant.exe" %*
http://img697.imageshack.us/img697/5623/castlebuildscreenshot.png http://img697.imageshack.us/img697/5623/castlebuildscreenshot.png
You can read the FM (how to build.txt). :)
You need to run the build script first using NAnt (http://nant.sf.net). This will generate the assembly.cs file. Take a look at the .build files in the tree to see what they are doing.
As for the assembly signing failing, check the project settings to get rid of references to CastleKey.snk. It should sign it using DynProxy.snk (in theory).
UPDATE:
The issue with NUnit is now fixed. Do a clean check out. I really have no idea why you're getting that error. Which version of NAnt are you using? Make sure you have the latest (earlier do not have support for .NET 3.5)
You should be able to just pull the source from the trunk, and build with nant (I just did that and it worked). Ok, I lied, looks like the reference to NUnit is wrong, so the unit test project will not build correctly:
BUILD FAILED - 0 non-fatal error(s), 1 warning(s)
D:\OLD\DynamicProxy\buildscripts\common-project.xml(295,5):
'nunit-console.exe' failed to start.
The system cannot find the file specified
Total time: 1.2 seconds.
BUILD FAILED
Nested build failed. Refer to build
log for exact reason.
Total time: 3.4 seconds.
However the important stuff (assemblyinfo generation) will succeed and you should be able to just open Castle.DynamicProxy2-vs2008.sln, fix the reference to the NUnit assembly hit F5 and build the code with no issues.
I just did it on a clean check out, and it worked.
Generally if you're planning to do modifications in DP codebase, it is advised to go to the Castle user group first, and discuss it there.