Build options in a visual studio solution with many projects - visual-studio-2012

Build options like "optimize code" "debug info - none", "no DEBUG constant" are defined on a project level in Visual Studio. In a solution with many projects a build is started with a specific visual studio build configuration that is added in one main project file (as XML).
The buid process also builds all dependency projects (dll's) and I wonder if it is possible to define the options mentioned above the main project file ("globally") or should each dependency project file be edited seperately?

It turns out that you must include all referenced projects as projects in the solution of the build job. Then the build configuration of the build is applied to all projects.
When you do not inlcude all referenced projects as projects in the solution, the build server will build all referenced projects in debug configuration.

Related

Android Studio referencing classes in an AAR published to local maven repo

I have a problem in Android Studio (3.1.2) referencing classes in an AAR published to my local maven repo.
I have successfully published an AAR file to my local maven repo and included it in a project that needs to use the AAR following this article:
https://medium.com/#kuassivi/tip-work-with-third-party-projects-locally-with-gradle-961d6c9efb02
Basically I have added a reference to mavenLocal() in the top level project in the repositories sections of buildscript and all projects. I have also added a reference to the AAR in the app gradle build (i.e. implementation groupid:artifactid:version). I have not done anything more than this.
If I do a gradle rebuild within Android Studio, everything compiles fine but if I edit a file that references classes in the AAR, the IDE cannot resolve the references.
When I do find class (i.e. cmd o), the IDE correctly finds the class within the classes.jar of the AAR and decompiles it.
I am guessing that this is happening partly because it cannot pick up the source jar that I published alongside the aar file to the local maven repo.
How do I get the IDE to pick up the source files and reference the classes in the AAR correctly? I would prefer to do this via a change in the gradle scripts rather than via an IDE wizard, if that is possible.
After more digging, I have discovered that the use of the maven repo is irrelevant because it is picking up the AAR file from the gradle cache in ~/.gradle/caches/transforms-1/files-1.1 not from the maven local repo. I can also include the sources files using "implementation com.company:artifact-name:0.8:sources". There is a good information here:
https://www.alonsoruibal.com/my-gradle-tips-and-tricks/
However Android Studio still cannot recognise the imports and though compilation works, the imports are marked in red in the editor. I guess there must be some magic with gradle that I am missing.
I put together a simple example on github here:
https://github.com/jmc420/kotlin_examples
In the multiproject folder there are 2 separate projects, one called "nested" which contains an android library project called "multiprojectlibrary" which "nested" references via a grade include.
The "multipleprojectlibrary" uses the maven publish plugin to publish the aar to mavenLocal via the command gradle publishToMavenLocal.
In the "independent" project "multipleprojectlibrary" is a dependency which is read from mavenLocal.
The "nested" project works reliably.
Using mavenLocal in the "independent" project seems very unreliable. Sometimes the "independent" project correctly uses the mavenLocal "multipleprojectlibrary" but when you make an update and publish again, the "independent" project starts using a copy of "multipleprojectlibrary" in .gradle/caches/transforms-1/files-1.1.
There seem to be 2 issues. One is that the "New Project" menu option of Android Studio only allows you to make an app; you can only make an Android Library via the "New Module", which puts the library as a sub project of an app. An option to create a "New Library" would solve this.
The other issue is that it is not clear how the maven local repo and the gradle cache interact. They seem to get out of sync and sync gradle does not seem to sync the gradle cache with the mavenLocal repo.

Building tess-two into a project using Android Studio's gradle build

There are answers about getting the tess-two project integrated into an Android project within Android Studio, but many are out-dated and none used the current capabilities defined here:
Using Android Studio 2.2 and higher, you can use the NDK to compile C and C++ code into a native library and package it into your APK using Gradle, the IDE's integrated build system. Your Java code can then call functions in your native library through the Java Native Interface (JNI)
What specific steps would be required to make tess-two functionality a part of the resulting APK, using functionality within Android Studio, rather than external file placement, manipulation and command line tools? So taking the building, creation of *.so files into the IDE. Specifically using just Android Studio's integrated build system (Gradle) as described here.
1. Start a new project
2. Import Tess-Two into the project
2b. Add any needed plug-ins
3. Add code in the main activity to get native functionality
4. Configure Android Studio build so that native functionality is available
This is where the specifics are required
4. Configure Android Studio build for native functionality
4a. Link C++ Project with Gradle
First, check the tess-two project for build files. You may select CMakeLists.txt or Android.mk files. Both are currently supported.
In this case, I used ndk-build, which seemed like a good bet for integrating the native code.
For more information, see Android Studio documentation
4b. Manage Long Commands
In Windows, errors may be encountered if the command length grows too large. To prevent problems, use LOCAL_SHORT_COMMANDS AND APP_SHORT_COMMANDS in the Android.mk file.
The "e=87" error is what you are avoiding by doing this:
For more on that topic, see stackoverflow question about error 87.
4c. Add Module Dependency for tess-two
In File > Project Structure > Dependencies use the + to add the tess-two dependency:
4d. Build the Project and check .apk file for .so files
The build, which takes a long time, should complete now. Validate that the .apk file contains the .so files, created during the build. With the tess-two libraries in an static initializer, run the project on your Android device:

VS publish vs dotless

When Visual Studio publish feature is used, it does not publish the css files created by dotless.
E.g. I have a less style sheet named Site.less and upon build it will create Site.css. However as the Style.css file is not included in the project it will not get published.
Appreciate any ideas.
Found it...http://haacked.com/archive/2009/12/01/t4-template-for-less-css.aspx
Add this template to you project. It will compile on change rather than on build.

Visual Studio 2012 doesn't build project on run when its dependencies change

I'm having a rather weird problem with Visual Studio 2012 lately:
Project A (C++ DLL) references project B (C++ static lib). No CLR.
Project A is set as my startup project (it has a debug command line set).
After changing a file in project B and hitting CTRL+F5, VS2012 doesn't build project A before launching it. It does build project B!
Research steps I've already taken:
After changing a file in project C, which is not referenced by either A or B, CTRL+F5 builds neither A nor B. This is expected.
After changing a file in project A itself, CTRL+F5 builds A. This is expected.
I've been able to reproduce this problem with project A' and dependency B'.
Configuration Manager: all projects are set to be built in my working configuration.
VS options:
"On Run, when projects are out of date:" = "Always build".
"Only build startup projects and dependencies on Run" is checked. Without it, it just build my entire huge solution when running project A, which is hardly what I want.
I should also note that we recently upgraded from Visual Studio 2010 (with which we did not have this problem).
I'm fresh out of ideas. Anyone?
It appears that this is the same problem described by these questions:
Visual Studio / MSBUILD does not update .lib files when sources are updated
Executable not rebuilt but object files recompiled
Solution: The intermediate folder for any VS project is not allowed to be under %TEMP% or %TMP%, and also may not be named "temp" (or maybe even contain the substring "temp"?).

Visual Studio InstallShield Project building error about localized resources

I created an InstallShield setup project in Visual Studio 2012. In the Application Files section of Project Assistan, I added "Primary output" and "Localized resources" files by using Add Project Outputs button after that completed all other sections. When I trying to build setup project, I'm getting an error like below.
Could not resolve Visual Studio .NET project output '{ProjectName}.Localized resources' from component {ProjectName}.Localized_resources
I have three different projects in my solution and I have got this error for two projects.
If there is no any localized resource in a project, InstallShield gives this error. To avoid this error (maybe you will complete all resources localization when project completed but you need to setup now) and complete setup project building, at least one resource file must be localized in project.

Resources