12
votes

I'm using Cordova to build an app, and I'm trying to get a Windows app to build. Using the Cordova CLI didn't yield any good results, so I tried to build the Visual Studio solution in the platforms/windows folder.

The problem is that it fails building and returns a long list of errors all of which pretty much just say something similar to this:

TS6054 Build: File 'C:/Code/ProjectClosr/Cordova App/platforms/windows/www/Gruntfile.js' has unsupported extension. The only supported extensions are '.ts', '.tsx', '.d.ts'.

Now, turns out that it thinks all of these files are TypeScript files, even though they are just Readme's, JavaScript files, CSS files etc. and it does that because for some reason all of those files in their properties have 'Package Action' set to TypeScriptCompile. Now, I didn't create this solution obviously, it was autogenerated by Cordova, but I need a way to fix this by somehow setting the 'Package Action' property for all of them back to their real values, instead of everything being a TypeScript resource.

How would I go about doing that?

4

4 Answers

13
votes

Looks like you have a TypeScript file somewhere inside the folder you are adding using the wildcard. Don't know why but MSVS changes Content type to TypeScriptCompile for the whole bunch of the files found by the wildcard you provide inside the folder.

In my case I had angular-ui-router.d.ts file inside www\lib\angular-ui-router\api.

Resolved by adding Exclude directive in CordovaApp.projitems file:

<Content Include="www\**" Exclude="**\*.ts" />

Also note that $(MSBuildThisFileDirectory) should be removed from the path since it magically breaks the trick.

3
votes

and it does that because for some reason all of those files in their properties have 'Package Action' set to TypeScriptCompile.

Just remove the <TypeScriptCompile ... keys from the solution by raw editing it. They are probably also already present as <Content ... which is what you need.

1
votes

According to this you should have set "allowJs": true inside your tsconfig.json to allow .js extension.

Hope this help!

"compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "outDir": "./scripts/",
    "allowJs": true
  }
0
votes

@Pavel Kozlov's solution worked wonderfully for me.

If you are using Cordova, you can use the following script to have it done automatically:

./reset_windows.sh

cordova platform rm windows
cordova platform add windows
sed -i '9s/.*/        <Content Include="www\\**" Exclude="**\\*.ts" \/>/' platforms/windows/CordovaApp.projitems

Make sure the old line you want to replace is actually line 9 as the 9s says at the beginning of the command.