Web发布未能遵守打字稿配置

时间:2016-04-02 16:55:05

标签: javascript typescript visual-studio-2015

在VS2015的两个独立实例中(update2 typescript v1.8)。 Web发布忽略tsconfig.json设置。特别是outDir。

我有这样的设置:

// tsconfig.json

{
    "compilerOptions": {
        "target": "es5",
        "sourceMap": true,
        "outDir": "../dist/",
        "noResolve": false
    },
    "exclude": [
        "../../node_modules",
        "../../bower_components",
        "../../typings"
    ],
    "compileOnSave": true
}

tsconfig.json位于app \ src文件夹中,在保存时会将输出生成到src \ dist文件夹中。这在开发模式下按预期工作,并允许我gitignore src \ dist文件夹并对azure上的webproject运行tsc.cmd -p app/src(当在webslots上使用源控件时)将重新生成js。

下的示例输入和输出
    app\
    app\src\
    app\src\tsconfig.json
    app\src\app.ts
    app\src\controllers\
    app\src\controllers\file1.ts
...
    app\dist\
    app\dist\app.js
    app\dist\controllers\
    app\dist\controllers\file1.js

但是,如果我将网络发布到目标服务器或本地文件系统上的文件夹,则会在复制app \ src \ app.js时出错。

Copying file app\src\app.js to obj\Release\Package\PackageTmp\app\src\app.js failed. Could not find file 'app\src\app.js'.  
    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets    Line 2998

Microsoft.web.publishing.targets的第2998行是

<!--Force Copy Of all file to the $(WPPAllFilesInSingleFolder) if needed-->
    <CopyPipelineFiles PipelineItems="@(FilesForPackagingFromProject)"
                           SourceDirectory="$(WebPublishPipelineProjectDirectory)"
                           TargetDirectory="$(WPPAllFilesInSingleFolder)"
                           SkipMetadataExcludeTrueItems="True"
                           UpdateItemSpec="True"
                           DeleteItemsMarkAsExcludeTrue ="True"
                       Condition="'@(FilesForPackagingFromProject)' != ''">

如果我将调试输出更改为详细并在输出中搜索app.js,我会看到两个实例

3>  C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.8\tsc.exe --project "PROJECTNAME\app\src\tsconfig.json"
3>Done executing task "VsTsc".
3>Done building target "PreComputeCompileTypeScriptWithTSConfig" in project "PROJECTNAME.csproj".
3>Target "CompileTypeScriptWithTSConfig" in file "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\TypeScript\Microsoft.TypeScript.targets" from project "..PROJECTNAME.csproj" (target "Compile" depends on it):
3>Building target "CompileTypeScriptWithTSConfig" completely.
3>Output file "app\src\services\app.js" does not exist.

4>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\Web\Microsoft.Web.Publishing.targets(2998,5): Error : Copying file app\src\services\app.js to obj\Release\Package\PackageTmp\app\src\services\app.js failed. Could not find file 'app\src\services\app.js'.
4>Done building project "PROJECTNAME.csproj" -- FAILED.

似乎期望输出就位,而不是输出目录。

更新:有一个Github问题跟踪此错误https://github.com/Microsoft/TypeScript/issues/6934

0 个答案:

没有答案