Issue 1:
Steps to reproduce:

Create new empty ASP.NET project in Visual Studio

Add TypeScript file to project

Accept prompt to add TypeScript functionality to project

From command-line, build the solution:

msbuild /p:DeployOnBuild=true /p:EnablePackageProcessLoggingAndAssert=true

The following error is logged:

(PipelineCollectFilesPhase target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(1289,5): error : The following two items have duplicate item metadata %(DestinationRelativePath). The two items data are <Item Name="MyScript.js"><DestinationRelativePath>MyScript.js</DestinationRelativePath><Exclude>False</Exclude><FromTarget>Unknown</FromTarget><Category>Run</Category><ProjectFileType>Default</ProjectFileType><OriginalItemSpec>MyScript.js</OriginalItemSpec><TargetPath>MyScript.js</TargetPath><FullPath>C:\dev\Sandbox\WebApplication8\WebApplication8\MyScript.js</FullPath><RootDir>C:\</RootDir><Filename>MyScript</Filename><Extension>.js</Extension><RelativeDir></RelativeDir><Directory>dev\Sandbox\WebApplication8\WebApplication8\</Directory><RecursiveDir></RecursiveDir><Identity>MyScript.js</Identity><ModifiedTime>2015-06-25 19:50:36.0037913</ModifiedTime><CreatedTime>2015-06-25 19:50:35.7134134</CreatedTime><AccessedTime>2015-06-25 19:50:35.7134134</AccessedTime><DefiningProjectFullPath>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\Microsoft.TypeScript.targets</DefiningProjectFullPath><DefiningProjectDirectory>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\</DefiningProjectDirectory><DefiningProjectName>Microsoft.TypeScript</DefiningProjectName><DefiningProjectExtension>.targets</DefiningProjectExtension></Item> and <Item Name="MyScript.js"><DestinationRelativePath>MyScript.js</DestinationRelativePath><Exclude>False</Exclude><FromTarget>CollectFilesFromContent</FromTarget><Category>Run</Category><ProjectFileType>Default</ProjectFileType><FullPath>C:\dev\Sandbox\WebApplication8\WebApplication8\MyScript.js</FullPath><RootDir>C:\</RootDir><Filename>MyScript</Filename><Extension>.js</Extension><RelativeDir></RelativeDir><Directory>dev\Sandbox\WebApplication8\WebApplication8\</Directory><RecursiveDir></RecursiveDir><Identity>MyScript.js</Identity><ModifiedTime>2015-06-25 19:50:36.0037913</ModifiedTime><CreatedTime>2015-06-25 19:50:35.7134134</CreatedTime><AccessedTime>2015-06-25 19:50:35.7134134</AccessedTime><DefiningProjectFullPath>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\CollectFiles\Microsoft.Web.Publishing.OnlyFilesToRunTheApp.targets</DefiningProjectFullPath><DefiningProjectDirectory>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\CollectFiles\</DefiningProjectDirectory><DefiningProjectName>Microsoft.Web.Publishing.OnlyFilesToRunTheApp</DefiningProjectName><DefiningProjectExtension>.targets</DefiningProjectExtension></Item>. [C:\dev\Sandbox\WebApplication8\WebApplication8\WebApplication8.csproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets(1289,5): error : The following two items have duplicate item metadata %(DestinationRelativePath). The two items data are <Item Name="MyScript.js.map"><DestinationRelativePath>MyScript.js.map</DestinationRelativePath><Exclude>False</Exclude><FromTarget>Unknown</FromTarget><Category>Run</Category><ProjectFileType>Default</ProjectFileType><OriginalItemSpec>MyScript.js.map</OriginalItemSpec><TargetPath>MyScript.js.map</TargetPath><FullPath>C:\dev\Sandbox\WebApplication8\WebApplication8\MyScript.js.map</FullPath><RootDir>C:\</RootDir><Filename>MyScript.js</Filename><Extension>.map</Extension><RelativeDir></RelativeDir><Directory>dev\Sandbox\WebApplication8\WebApplication8\</Directory><RecursiveDir></RecursiveDir><Identity>MyScript.js.map</Identity><ModifiedTime>2015-06-25 19:50:35.7124176</ModifiedTime><CreatedTime>2015-06-25 19:50:35.7124176</CreatedTime><AccessedTime>2015-06-25 19:50:35.7124176</AccessedTime><DefiningProjectFullPath>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\Microsoft.TypeScript.targets</DefiningProjectFullPath><DefiningProjectDirectory>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\TypeScript\</DefiningProjectDirectory><DefiningProjectName>Microsoft.TypeScript</DefiningProjectName><DefiningProjectExtension>.targets</DefiningProjectExtension></Item> and <Item Name="MyScript.js.map"><DestinationRelativePath>MyScript.js.map</DestinationRelativePath><Exclude>False</Exclude><FromTarget>CollectFilesFromContent</FromTarget><Category>Run</Category><ProjectFileType>Default</ProjectFileType><FullPath>C:\dev\Sandbox\WebApplication8\WebApplication8\MyScript.js.map</FullPath><RootDir>C:\</RootDir><Filename>MyScript.js</Filename><Extension>.map</Extension><RelativeDir></RelativeDir><Directory>dev\Sandbox\WebApplication8\WebApplication8\</Directory><RecursiveDir></RecursiveDir><Identity>MyScript.js.map</Identity><ModifiedTime>2015-06-25 19:50:35.7124176</ModifiedTime><CreatedTime>2015-06-25 19:50:35.7124176</CreatedTime><AccessedTime>2015-06-25 19:50:35.7124176</AccessedTime><DefiningProjectFullPath>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\CollectFiles\Microsoft.Web.Publishing.OnlyFilesToRunTheApp.targets</DefiningProjectFullPath><DefiningProjectDirectory>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\CollectFiles\</DefiningProjectDirectory><DefiningProjectName>Microsoft.Web.Publishing.OnlyFilesToRunTheApp</DefiningProjectName><DefiningProjectExtension>.targets</DefiningProjectExtension></Item>. [C:\dev\Sandbox\WebApplication8\WebApplication8\WebApplication8.csproj]

I think the problem is that the file is being added twice. Once by TypeScript\Microsoft.TypeScript.targets and also by Microsoft.Web.Publishing.OnlyFilesToRunTheApp.targets

Issue 2:
Typescript compiler lacks a native way of maintaining compilation options and source files for a given compilation unit like a project or a module. Using /// can help ease the problem, but there is still a tax of adding and managing the references and it does not handle the compilation options issue. Moreover, different editors have different ways of representing project or module structure and compilation options which make cross-editor collaboration tricky.

The proposal is to introduce a new file .tsconfig that marks a compilation unit (aka project or module). The .tsconfig follows the footsteps of the .git* file family. Calling tsc in a directory with a .tsconfig will use the contents of the file and all .ts files in the directory as inputs without the need to specify them on the command line again.

.tsconfig in detail

.tsconfig is a json file

The presence of a .tsconfig in a directory indicate that all .ts file in this directory and its sub directories recursively are part of the compilation unit

.d.ts files generated from the compilation but live within the directory are not included in the compilation unit identified by .tsconfig

.tsconfig can specify additional compilation settings for the compilation

Calling tsc in a folder containing .tsconfig will trigger compilation using the config file

Since .tsconfig is a json file, it can be leveraged by other tools (linters, editors, build tools etc..) to store TS related project configuration

Example .tsconfig

{
"compilerOptions": ["-t ES5", "--out myoutput.js", "--noImplicitAny"],
"linterOptions": {
"suppressWarnnings": [234, 3363]
}
}

Module example

Consider the following directory structure:

shared/
node.d.ts
tools.ts
foo/
.tsconfig
a.ts // adds a ///<reference> to node.d.ts
b.ts
bar/
.tsconfig
c,ts // adds a /// <references> to tools.ts
d.ts
baz/
e.ts

Calling tsc in "foo" is equivalent totsc a.ts b.ts

Calling tsc in "bar" is equivalent to tsc c.ts d.ts baz/e.ts

Using .tsconfig with tsc

When calling tsc with no input files, the following steps are taken:

Find the owning .tsconfig file by walking up the directory structure until a .tsconfig file is found, or the drive root is reached

If a .tsconfig was found, compilation will be triggered with all .ts files in the directory containing the .tsconfig and all its sub directories

The command line switch are compiled with the configuration options from the .tsconfig defining the compilation command line flags (e.g.: tsc --watch will cause a tsc to compile the contents of the current project in watch mode)

When calling tsc with input a single directory name (e.g.: tsc compiler), If the directory contains a .tsconfig at the root, steps 2 and 3 from above are followed.

Specifying output order with --out and .tsconfig

when using --out, the compiler relies on the order of the files passed on the command line to order the emitted JavaScript code. If using .tsconfig, the compiler will look for a special file _references.ts at the root (next to the .tsconfig file), and will ensure that this file is the first file in the list of input files. this implies that /// tags in _references.ts will specify order of the emitted files.

Open issues:

Should the tsconfig file have a .json extension to indicate intended content, and allow editors to correctly colorize it, format it, etc..

In a VS project context (say .csproj), should .tsconfig be honored, or ignored in favor of the project.