ค้นหาเว็บไซต์

javascript - Webpublish ล้มเหลวในการเคารพการกำหนดค่า typescript


ในสองกรณีแยกของ VS2015 (update2 typescript v1.8) การเผยแพร่เว็บไม่สนใจการตั้งค่า 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 ได้ และการรัน tsc.cmd -p app/src กับโปรเจกต์เว็บบน Azure (เมื่อใช้การควบคุมซอร์สบน 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

บรรทัดที่ 2998 ของ Microsoft.web.publishing.targets คือ

<!--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

บทความที่เกี่ยวข้อง