Build Android apps on TFS 2017 using Android Studio OpenJDK? - tfs

I want to build Android apps on a local TFS 2017 build agent - local TFS 2017 server also.
Android Studio now contains OpenJDK but I couldn't get the TFS 2017 Gradle task to work without installing Oracle's JDK. I tried creating a JAVA_HOME environment variable, using the set JAVA_HOME by JDK version in the TFS Gradle task, and the set JAVA_HOME by path in the TFS Gradle task.
Looks like having Oracle's JDK is the standard for TFS (it's installed on Microsoft's hosted build agents) but I'd like to do without because of the incoming JDK 8 licensing change.

Unfortunately you have to install the Oracle's JDK first if you are using windows build agent, it's one of the prerequisites.
Before you set up Android Studio, be sure you have installed JDK 7 or
later. The Java Runtime Environment (JRE) alone is not sufficient.
Even with the Linux agent, when you running OpenJDK, the installer will tells
"SYSTEM HEALTH OpenJDK shows intermitten performance and UI issues. We recommend using the Oracle JRE/JDK" Reference this similar thread: Can Android Studio use OpenJDK or does it require Oracle JDK on Linux?
More information you can reference below articles:
How to install the Android SDK on Windows, Mac and Linux
Digi Embedded for Android > Get started > Step 4: Create your first
application > Step 4.1: Install the software

The Gradle task doesn't like a JDK path containing spaces. I couldn't get any kind of quotes to work and 8.3 name creation is disabled on the build machine.
I've created directory links with mklink /d for the 2 directories that have spaces in their names. Then in the Gradle task advanced options selected set JAVA_HOME by path and set the path to C:\Program-Files\Android\Android-Studio\jre Works fine now.

Related

Jenkins: Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8

I am facing issue in jenkins job(jenkins running docker) Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
I have checked java version in docker it is openjdk version "11.0.12" 2021-07-20
we can solve this in Android Studio but how can we solve while running gradle build in jenkins.
Below is the error I am getting
Build file '/var/jenkins_home/workspace/CICDDemo_master/app/build.gradle' line: 2
What went wrong:
An exception occurred applying plugin request [id: 'com.android.application']
Failed to apply plugin 'com.android.internal.application'.
Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing org.gradle.java.home in gradle.properties.
In your Jenkins project choose the "configure" tab on the left side, then scroll down to "Properties Content" and write there:
JAVA_HOME=C:\Program Files\Java\jdk-11.0.12
GRADLE_USER_HOME=C:\

How to build a Windows driver development kit 7 on 10

I am trying to build a Windows driver for a piece of hardware I am using. The build notes seem dated as they specify using DDK for Win7. I have Windows kit version 10. Are these the same thing just later version? The instructions then state to open a DDK command window environment then use "build -ceZ" in the dir where the files are located. Does v10 have this console and if so where can I find it? Thanks
https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/wdk-and-visual-studio-build-environment
"The Windows Driver Kit (WDK) 8.1 and WDK 8 introduced a major change
to the environment that you use to build a driver. The WDK no longer
uses Build.exe. The WDK build environment for drivers uses MSBuild.exe
and is fully integrated with the Visual Studio development
environment. This means that source files, makefile.inc, makefile.new
and other related build files present in the previous version of the
WDK are no longer used. The WDK now enables you to create, edit,
build, test, and deploy a driver through Visual Studio. The purpose of
this document is to provide information to help users familiar with
previous WDKs in getting started with the WDK 8.1 and WDK 8."
If you want to build the driver as is then you will need to install the Windows 7.1 DDK and build it using its tools.
https://en.wikipedia.org/wiki/Windows_Driver_Kit
https://www.microsoft.com/en-gb/download/details.aspx?id=11800
You are allowed to install different versions of the DDK on the same machine.
You might find it tricky to install DDK 7.1 on Windows 10 though, try and use this to get around any problem install.
https://stackoverflow.com/questions/32091593/cannot-install-windows-sdk-7-1-on-windows-10#:~:text=If%20you%20continue%20with%20Setup,187668%20and%20then%20rerun%20Setup.
Then it's just a case of "choosing the 7.1 ddk environment (32bit or 64bit)" so that it's tools are accessible/used when "building" your driver.
Look in your startmenu at "StartMenu -> Windows Driver Kits -> WDK XXXX -> Build Environments" to find a command prompt to open.
If you can't/don't want to install the DDK 7.1 and a WDK8+ version of your driver project isn't available then it may be possible to convert the driver from using the older "makefile" into new msbuild way of building, but might be fiddly.
https://community.osr.com/discussion/289475/build-exe-to-msbuild-exe-migration-advice
"If you go into VS you should be able to create a WDK driver project.
It will give you a solution with (I think) one C file filled with
everything necessary to make a driver which does nothing. But, most
importantly, it will generate an XML file that MSBuild will accept.
The XML format is not documented. After you have this XML file you
should be able to figure out how to add your files to it by hand, but
you could move the existing driver files to the project using the GUI.
That may be easiest."

"System cannot find the file specified" when adding a new Azure IoT Edge module in Visual Studio

I've followed these steps exactly and am getting the error below:
Select File > New > Project...
In the new project window, search for IoT Edge and choose the Azure IoT Edge (Windows amd64) project. Click Next.
In the configure your new project window, rename the project and solution to something descriptive like CSharpTutorialApp. Click Create to create the project.
In the Add Module window, configure your project with the following values:
Select Add to create the module.
I get this error regardless of the combination of solution folders, module names, and any other parameters that I enter during this workflow:
The system cannot find the file specified. (Exception from HRESULT: 0x80070002)
The net result is that no changes are made to the solution -- no IoT Edge module project is created, no other files are altered.
I've tried running Visual Studio 2019 (16.4.3) as administrator, uninstalling and reinstalling the Azure IoT Edge Tools extension, all without success.
What can I do to troubleshoot this further?
Update 1: I've double-checked all documented prerequisites and still have this issue.
Visual Studio 2019 16.4.3, all prerequisite Visual Studio workloads installed
.NET Core workload installed the latest -- 3.1 LTS SDK -- only. Is there a hidden dependency on a specific older .NET Core 2.x SDK somewhere? Or is the documentation for VS Code on the subject out of date? (I'm using VS but was looking everywhere to see if I had missed anything)
Git for Windows installed (via Visual Studio Installer)
Docker Windows Desktop installed & switched to Windows containers
Azure IoT Edge Tools for VS 2019 installed (and uninstalled & reinstalled)
no UNC/FQ paths in the item or project template locations:
C:\Users\larsk\OneDrive\Documents\Visual Studio 2019\Templates\ProjectTemplates
C:\Users\larsk\OneDrive\Documents\Visual Studio 2019\Templates\ItemTemplates
multiple reboots
this is on a machine that just recently got the latest (1909) version of Win10 Pro reinstalled on it.
Update 2: Updating to Visual Studio 2019 16.4.4 did not help either.
The solution turned out to be running a Repair operation through the Visual Studio Installer.

An exception occurred while invoking executor 'executor://xunit/VsTestRunner2/uap': Could not load file or assembly 'System.IO.FileSystem

I'm facing to an issue when I'm running my unit tests on a VSTS build.
When I'm launching all my tests on Visual Studio locally, everything works fine. No error at all. Perfect.
But when I'm launching my tests via a tests task on a VSTS build, I have this error:
An exception occurred while invoking executor
'executor://xunit/VsTestRunner2/uap': Could not load file or assembly
'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral,
PublicKeyToken=***********' or one of its dependencies. The
system cannot find the file specified.
My test project is set like this:
"xunit.runner.visualstudio" on version 2.4.0 with a "targetFramework" set to "net462" (set inside the packages.config)
.NET Framework 4.6.2
On the build server I have:
Visual Studio 2017, v15.7.5
Visual Studio 2015, v14.0
I'm running out of clues... I'm surely missing something...
Thanks for your help
PS:
All tests passed correctly on the VSTS build
On the settings of my build task, when I set "Test platform version" to "Visual Studio 2015", it works. But when I'm choosing "Visual Studio 2017" or "Latest" I have the same error...
EDIT
I have Nuget packages "FluentAssertions" v5.4.1 and "System.ValueTuple" v4.5.0. I already tried to downgrade one of them and both. It failed. But I saw that "FluentAssertions" has a dependency to "System.ValueTuple"
EDIT 2
As #PatrickLu-MSFT said, passing the vs test task version to 1 solved the issue.
But when I'm looking closely, the Test platform versions available are 2015 and 2013:
When I'm choosing VS test task version 2, I have those choices:
I would like to stay on vs test task version 2 (in case of future updates, I don't want to be stuck...). What I saw is when I'm on Test platform version set to "Latest" or "Visual Studio 2017", it does not work. When I'm choosing "Visual Studio 2015", it working...
So what I point is:
Having a vs test task version set to version 1 make it work (maybe because the latest test platform version is "Visual Studio 2015"...?)
Having a vs test task version set to version 2 with Test platform version set to "Visual Studio 2015" make it work
So:
A VS test task version set to version 1 seems to work the same way as a VS test task version set to version 2 with a "Test platform version" set to "Visual Studio 2015".
How can I make it work with a VS test task version set to version 2 and a "Test platform version" set to "Latest"?
EDIT 3
After connected remotely to the server of my build agent and run tests from VS2017, I compare the output of Visual Studio 2017 of the host server to the output of my local Visual Studio 2017:
Local Visual Studio 2017:
Remote Visual Studio 2017:
Are there some issues with "xUnit.net VSTest Adapter v2.4.0 (32-bit Universal Windows)" on the host?
I hit this same problem and solved it by changing the "Path to custom test adapters" to point specifically to the correct test adapter by setting it to "Source\packages\xunit.runner.visualstudio.2.4.0\build_common". (You should modify the path to account for where the packages folder is in your repository.)
This apparently happens because by default VSTS tries to be helpful and scans the entire working directory structure for test adapters and loads all of them, but the xUnit Visual Studio test adapter Nuget package installs test adaptors for .Net Core and UWP as well, so VSTS happily loads them and they blow up.

Can I do database deployments, without installing Visual Studio or VSTSDB?

In setting up our TFS 2010 build machine we are trying to avoid installing Visual Studio (2005/2008/2010). For most builds just installing the necessary SDK has allowed us to get good builds w/o visual studio.
However, with VSTSDB (Visual Studio Team System Database for professionals) I'm unable to identify what (if any) SDK is available to be installed rather than installing VSTSDB on the build machine. Does such an SDK exist?
The TFS 2010 Build Service can build Database Projects out-of-the-box. It doesn't require any additional components.
Another way to deploy a database project from the command line, is to use the VSDBCMD utility.
The install process is as simple copying some binaries onto your build machine.
This negates having to install Visual Studio or TFS.
This comes in very handy, where you might be doing manual/adhoc installs on machines where team foundation server isn't installed.
Microsoft recommend this too, see:
How to: Prepare a Database for Deployment From a Command Prompt by Using VSDBCMD.EXE
Note:
Ensure you read the section titled Special Requirements for 64-bit Operating Systems, as you will need to install the correct versions of SQL Server CE for this to work correctly.

Resources