The problem starts with 'dotnet test' command. For some reason, the project with tests can't find a shared library that should be available for it (see a screenshot attached). As you may notice, I'm running the task via Azure DevOps using a custom agent (I think it doesn't really matter). From the logs I realized that the reason it works locally on my machine is that the project I'm talking about is being built in Debug mode in Visual Studio and this is exactly the folder the test project is looking for the library (i.e. \bin\Debug\netstandard2.0\my.dll).
The issue appears when I run 'dotnet test' as a task in the build pipeline in Azure DevOps and the process does not create Debug folder for this exactly project. It's weird, because 'dotnet test' builds solution once again (in the debug mode) and the folder should be generated.
I tried switching the project from 'netstandard2.0' to 'netcoreapp2.2' and adding xunit testing libraries. They're not required in this project but it has started producing Debug folder with compiled libs in it (i.e. \bin\Debug\netcoreapp2.2\my.dll). However, it didn't resolve the issue because the test project still looking for the lib in 'netstandard2.0' folder.
I expect the test projects will be relying on the libs available in Release directory (instead of Debug). Can't get how to achieve this.
You are referencing the DLL in the test project , instead add the reference of the project itself to it.
Related
I have been going crazy trying to fix this publishing issue for days. I have a VSTO application for Office that builds using MSbuild.exe successfully, in both debug and release. The problem arises when I try to run MSbuild like such: MSBuild -t:publish. The funny thing is, when I use the publishing wizard in Visual Studio 2019 Community, my application publishes properly. I only have issues when trying to use MSBuild.exe with the publish target, not with normal builds.
By right-clicking my project in VS 2019 and clicking Publish, I see this wizard which produces the expected result.
Expected Result:
MSbuild produces a publish directory with a .vsto file for my application along with a a reference directory with dependencies and/or a setup.exe
The expected result of running MSbuild with the publish target.
Actual Result:
When running MSBuild -t:publish in a command line that is CD'ed to the directory of my project, I get this error:
Project "D:\repositories\myapp\myapp.sln" (1) is building "D:\repositories\myapp\myapp
.csproj" (2) on node 1 (Publish target(s)).
_DeploymentUnpublishable:
Skipping unpublishable project.
Things I tried:
I tried a lot of things to get this to work. I read these threads:
First thread : Applies to ASP.net applications not VSTO, also says that McAfee can cause issues. I disabled all antivirus on my machine, still no luck. I have tried adding properties such as: /p:DeployOnBuild=true /p:OutputPath="publish/" /p:PublishDir="publish" /p:VisualStudioVersion=16.11 (my version) and all combinations of these and it never worked. I tried using /t:Package but I get the error: error MSB4057: The target "Package" does not exist in the project.
Adding <OutputType>winexe</OutputType> to my .csproj does not work because this application produces a DLL on normal builds, not an executable.
Second thread
I already have this installed. I'm testing the command line publish on my local development machine before I try this on the build server.
Third thread I am not using a shared add-in.
Fourth Thread ITT and others, they recommend using a .pubxml but I cannot figure out how to make one of those, AFAIK they are generated by ASP.net applications and not applicable to a VSTO application. I could be wrong, but again I don't know how to create one properly.
Fifth Resource This is a lot of stuff to do, and I am confused if it will even work. I DO have VS 2019 installed, my program builds successfully and runs successfully, and even publishes successfully when using the publishing wizard. I am not using TFS. I am just trying to produce the VSTO via command line.
For anyone who runs into this problem, it is because you are not loading:
Microsoft.VisualStudio.Tools.Office.targets
I wish the log would have been more specific about that.
I created a Wix setup project for my .Net app (using Wix 3.11.1) with files, shortcuts, custom UI, custom action and all.
The solution itself contains a large number of .csproj-s, the Wix setup project and a Wix Custom Action project.
When I build it from Visual Studio (2010, heading towards 2017), the build seems to be correct, I get "Build succeeded".
However, my automated build script (which cleans the solution and then runs MsBuild against the solution) fails, because the Wix Setup project is built before the Custom Action project.
The custom build script is simple:
MsBuild.exe .\<solutionname>.sln /target:Rebuild /property:Configuration=<config> /property:Platform=<platform>
I tried adding a reference to the Wix setup project pointing to the CA project, hoping that the reference would tell MsBuild to build the CA project first, and then build the setup project. It didn't work.
If I run the same build script again (now the CA project having been built) the scripted build succeeds.
Can I somehow tell MsBuild to build the projects in the correct order?
I'm currently using MsBuild from .Net FW 4.0 (%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe)
Any ideas?
A solution exists here (see the highest voted comment saying "It's a bug, bug, bug...".
Why does Tfs2010 build my Wix project before anything else?
In short: you need to re-order your projects in the solution file using a text editor.
I'm trying to set up a Jenkins server for my C# Project. The Server currently runs on my localhost as I'm testing it out.
So far, I've managed to restore NuGet packages, and build the project, using 2 steps in the Build config.
Now, I'm trying to have it execute our unit tests. The tests are made using Microsoft's own test framework.
I initially tried to use the plugin to run the tests, and also set it up using a windows bat file, both result in the same problem.
The dll assembly cannot be found.
My bat command looks like this:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\MSTest.exe" /resultsfile:"%WORKSPACE%\Results.trx" /testcontainer:"%WORKSPACE%\msTests\bin\Release\netcoreapp2.0\msTest.dll" /nologo, the result being: Test file not found.
I assume this is because Jenkins removes the build assemblies on success? How can I disable that? Or something else I'm doing wrong?
If you are using dotnet core you should be using the dotnet test command.
https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-test?tabs=netcore21
I've set up a build controller and build agent for my TFS 2012.
I have a .NET 4.0 project with coded UI tests that I would like to run there.
I set the build configuration to run with VS Test Runner.
The problem is that the test runner skipping all of my tests!
(I can see Skipped <test_name> for all my tests in the log view when I run the build with Diagnostic logging verbosity)
Any ideas?
update -
I've googled a lot on this and found that adding a .testsettings file in the build configuration should solve this, but when I added one, the build fails with the following error (found nothing about this error :( ):
MSTestAdapter could not run the test as the classic mode is not available. Reason: Exception has been thrown by the target of invocation.
Directory C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\DataCollectors does not exist
and with this warning:
No tests is available in . Make sure that installed test discovers & executors, platform & framework version settings are appropriate and try again.
To run coded ui test in build server, you needed to run the build agent as an interactive process (Build service property, Run as Interactive Process), you also need setup a test controller and an interactive test agent.
http://msdn.microsoft.com/en-us/library/vstudio/ms181712.aspx#interactive
http://msdn.microsoft.com/en-us/library/dd648127.aspx
in your testsettings you can sepcify the testagent and other settings
http://msdn.microsoft.com/en-us/library/ee256991.aspx
My company is moving to continuous integration using Jenkins.
We keep our code in Subversion.
We code in C# (well I do, the others use php).
I've hit a snag, I can't get nUnit to work when I compile the project .
My project is a very simple one with just a single class and a few nUnit tests.
Works fine in Visual Studio. It builds and I can run the NUnit console to test the code.
I can use Jenkins to extract the project from Subversion
I can then build the code with msBuild.
However, when I try to run NUnit from the the NUnit console I get told that nunit.framework.dll is missing.
nunit.framework.dll is in C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\framework
I think it is looking for the nunit.framework.dll that is referenced by the project. Which is required to add NUnit tests to the project.
I note that when building from Visual Studio nunit.framework.dll is copied to the bin folder.
I note that no contents of bin are stored in Subversion.
I had to put a copy of nunit.framework.dll into
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Profile\Client
so that msBuild could find it.
How do I get nunit.framework.dll into the output bin folder when using Jenkins and msBuild?
I've looked through a number of posts but non address this point.
Any thoughts would be welcome.
Thanks,
Richard
In your Test project where you reference the Nunit.Framework.dll, right click on that and select properties ( or press Alt + Enter ) and make Copy Local to be True
Subversion does not store output files ( i.e. dlls) by default. I rebuilt the project and added nunit.framework.dll to subversion. That way it gets popped out by Jenkins and can subsequently be referenced.