Typescript giving "Output Generation Failed" in Visual Studio 2012 with 0.9.5 - visual-studio-2012

I've been using Typescript 0.9.5 for the last few days, and then suddenly today the JavaScript files just stopped being generated. I see an error "Output generation failed" in the Visual Studio status bar, but nothing in any of the output windows.
I've rebooted, and restarted Visual Studio, disabled Web Essentials, tried all the usual things.
The files are set as TypescriptCompile in the properties. I've tried adding new files, or editing old ones with no effect. The Project file hasn't been changed as far as I can tell (its in TFS and none of the TypeScript sections have been altered).
I've made sure both files are checked out, still nothing.
Update: I've managed to compile manually using tsc.exe from the command line, so it must be something in Visual Studio.

OK, so I solved the problem.
One of my files contained invalid typescript, specifically trying to export a class when not inside a module. This caused all typescript files to fail to generate, but with no useful error message.
The following file would cause the problem:
export class Test {
public DoSomething() {
}
}
Either removing the export keyword, or adding a wrapping module solved the problem.
I've raised it as an issue here: https://typescript.codeplex.com/workitem/2109
Update: More details.
The above syntax is valid if you are using the CommonJS or AMD module patterns.
To enable this in visual studio you need to edit the .csproj file and insert a new PropertyGroup:
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>

If you have an export outside of an internal module Typescript tries to compile it as either commonjs or amd module format. The compilation will fail if the a --module flag is not present on the command line. Use your project properties to set it to the desired value (probably amd in your case).
More info on TypeScript modules : http://www.youtube.com/watch?v=KDrWLMUY0R0&hd=1

Related

Debug target is an old version of NUnit that isn't present on computer

When trying to debug a project which I have successfully debugged many times before and which compiles without incident, I'm now getting this error:
Visual Studio cannot start debugging because the debug target 'C:\Program Files (x86)\NUnit 2.6.2\bin\nunit.exe' is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly.
Looking at Program Files (x86), I can see that the reason VS can't find the file is that it doesn't exist. The version of NUnit it should be looking for is 2.6.4, not 2.6.2.
What I can't find, however, is any way to tell VS where to look. The OutputPath and AssemblyName properties referenced in the error message both seem unrelated to the issue, and there isn't any setting I can find that references NUnit at all, much less a particular version of it.
In following advice from some of the many other questions about this error, I have tried the following without success:
Cleaning and rebuilding the solution
Cleaning and rebuilding the individual projects within the solution
Looking at the project and solution files in a text editor (They all show NUnit 2.6.4)
Making sure the projects are all checked in the Configuration Manager
Checking the projects' debug properties
As stated above, neither the .sln files nor any of the .csproj files contained any reference to NUnit 2.6.2, but I finally found a reference to it in a .csproj.user file for one of the projects:
<StartProgram>C:\Program Files %28x86%29\NUnit 2.6.2\bin\nunit.exe</StartProgram>
Changing the version number there fixed the issue.

ProGuard issues with Android Archieve(.aar) library

I've a library project which I want to distribute, in AAR format. I've applied ProGuard on it.
ProGuard settings works well if I use this lib as a module, but not when I use resulting AAR. Basically it fails with exception "java.lang.IllegalArgumentException: already added Lmy/lib/package/name/R;" in Application project.
ProGuard is renaming one of my lib class to R, and I feel which is causing problem in Application project as R is used for Resources.
How do I specify proguard mapping in Studio to tell it not to rename to R.
Update:
after adding AAR file as a new module, am getting this error:
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lmy/lib/package/name/R;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:189)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:454)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:303)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at com.android.dx.command.dexer.Main.main(Main.java:215)
at com.android.dx.command.Main.main(Main.java:106)
Okay then, answering myself.
Tried running ProGuard manually on .aar, worked with latest version v5.2.1. Didn't work with default version v4.7 which came with Studio v1.2.2. Hope this helps.

From Eclipse to Android Studio: Why is proguard.cfg used when NOT building Release?

So, I have been trying to migrate the development of a multi-project (eclipse projects that is) app to Android Studio (v1.1).
Importing via File > Import Project was really easy and went without incident.
However, when I tried Make/Rebuild project I encountered numerous surprises. The first, not Proguard-related, had to do with source file encoding (originally in Windows-1252), but I quickly found a solution using this Windows-1252 > Reload > UTF-8 > Convert answer.
Then, "error: cannot find symbol class" for a com.comp.mod.X class of mine. I then solved it by going to the module (Android Studio module that is, previously an Eclipse project) that contains that class and added to its proguard.cfg the following:
-keep public class com.comp.mod.X
Which left me with an "error: cannot find symbol variable" for a const BB defined in the aforementioned class. I solved this by adding to the same proguard.cfg the following:
-keepclassmembers class com.comp.mod.X {
public static final boolean BB;
}
That left me with only one "error: cannot find symbol method getPreferenceX()". I solve this by adding to the same -keepclassmembers that method, so that the above now looks:
-keepclassmembers class com.comp.mod.X {
public static final boolean BB;
public static java.lang.String getPreferenceX();
}
I thought I was done, but to my dismay, when I attempted to rebuild the project, I received numerous additional errors from other modules in the project, all of the type to "error: cannot find symbol class/variable/method" and related to some proguard.cfg.
I could have continued butchering the proguard.cfg files for each and every module but at this point I am beginning to suspect that I am doing something fundamentally wrong, because those proguard.cfg files work perfectly under Eclipse. So,
Why all of a sudden these are no longer good for Android Studio?
If ProGuard runs only when you build your application in release mode, why is the Android Studio based build complaining about "cannot find symbol" due to Proguard's obfuscation?
What am I missing?
Note: I have not attempted "Generate Signed APK". All I do is "Rebuild Project".
Currently (as of 2015-04-24), minifyEnabled's default value of false for all build types is incorrect for multi-module projects, in which some modules (app included) are dependent on other modules. This is due to bug #52962 that causes build types to not propagate to libraries -- they are always built as RELEASE.
Suggestions to work around this bug or notifications of its fix are most welcome.

Undeclared variable with LESS #import. What is causing this? Is there a fix?

I have 2 LESS files. Globals.less and Site.less. Globals.less contains all of my global (go figure) variables and an import to a CSS reset definition. Site.less contains the styles in use.
Globals.less:
//Imports
#import "CSSReset.less";
//Colors
#color-background: rgb(0, 0 , 0);
Site.less:
#import "Globals.less";
body {
background: #color-background url('/Images/BackgroundTextureBody.png');
}
The problem is this: In Visual Studio #color-background in Site.less is underlined and the error is "Undeclared variable", but the LESS compiles to CSS just fine and the background color is properly set to #000. It is more of an annoyance than anything, but I lose Intellisense and I get warnings in my error list. I would like the editor to act as expected and be able to "see" my declarations in Globals.less when I am editing Site.less. Am I doing something wrong, is this a bug, or is my environment not setup correctly?
To get intellisense for a particular less file you can add a reference path in the same way you would to get intellisense in a js file.
Example
/// <reference path="Globals.less" />
#import "Globals.less";
body {
background: #color-background url('/Images/BackgroundTextureBody.png');
}
It appears that Visual Studio (or it's LESS interpreter) does not understand the scope of the variable within the imported Globals.less
Importing variables is a normal and common thing to do so I'd suggest that it's a bug or missing feature in your Visual Studio setup.
It turns out that I was using an older version of Web Essentials 2012. The first thing I should have checked and failed to do was to ensure that my environment was up to date. Updating Web Essentials to the latest version corrected the issue.

How do I eliminate error C2859 when trying to use a precompiled header with VS2010 (VC100) in debug mode?

I am trying to upgrade an old solution to use VS2010 (VC100).
I have it setup so that stdafx.cpp will create a precompiled header stdafx.pch from stdafx.h. Then all the other .cpp files that include stdafx.h are instructed to use the precompiled header.
These posts helped me get this far:
Visual C++ Precompiled Headers errors
Precompiled Headers
Now all is fine when I build in release mode. However when I try and build in debug mode I get a whole heap of errors saying:
Error 1 error C2859: [removed]\debug\vc100.idb is not the idb file that was used when this precompiled header was created, recreate the precompiled header.
I believe that this .idb file is an intermediate debug file created by Visual Studio.
Why am I getting this error? In other words why did it not use this .idb file when it created the precompiled header?
I'm not sure what further information you need to be able to give me answer so just ask if there is more information that I need to provide.
Thanks to a colleague I got the answer.
The problem was that stdafx.cpp had Debug Information Format set to Program Database (/Zi) where as all the other files had it set to Program Database for Edit and Continue (/ZI).
Changing them all to Program Database for Edit and Continue (/ZI) and doing a full rebuild solved the problem.
I guess the upgrade screwed it up somehow.
I've hit this error with VS2005 when compiling a project where the $(ProjectName) is different from the actual output file of the project (i.e. Linker > Output File isn't set to the default of $(OutDir)\$(ProjectName).exe but to something else, e.g. $(OutDir)\$(ProjectName)-custom_postfix.exe)
In this case, and apparently only when doing a Rebuild-Project-Only, the vc80.pdb seems to be looked up wrongly.
What helped me was to additionally set C/C++ > Output Files > Progam Database File Name to $(IntDir)\$(TargetName).pdb. (Instead of the default vc80.pdb)
select Disable for the Debug Information Format in the Properties page for stdafx.cpp, then go back and select Inherit from parent worked for me.
Maybe your release build is configured to write file [removed]\debug\vc100.idb instead of [removed]\release\vc100.idb? Check the project settings for your release build and make sure there are no hardcoded path components like that.
Here's how I just fixed this error on Visual Studio 2008:
Background:
I have a solution that contains two sub-projects.
One project compiles the .dll;
One project compiles the .exe that used this .dll;
The .exe project is dependent on the .dll project;
Problem: I had both of the projects dumping their output into the same directory, i.e. both "OutPutDirectory" and "IntermediateDirectory" set to write to a common directory in the root, "../$(ConfigurationName)".
Cause of error:
The cause of this error was that when the .dll project was compiled, it created the precompiled header (*.pch) in the same directory as the .exe directory, and when the .exe project was compiled, it promptly overwrote the precompiled header (*.pch) from the .dll project.
The fix:
To fix this, I changed the "IntermediateDirectory" for both sub-projects to "temp", so that the temporary files (including the precompiled header files) were written to different directories.

Resources