顯示具有 Visual Studio 2015 標籤的文章。 顯示所有文章
顯示具有 Visual Studio 2015 標籤的文章。 顯示所有文章

2016年5月16日 星期一

Angular 2 RC1 error handling in VS2015

自從升級至 Angular2 RC1 後,
VS2015 一直提示以下錯誤訊息:
  1. Invalid module name in augmentation, module '../../Observable' cannot be found.
  2. Property 'map' does not exist on type 'Observable'


可是又 Build 得過,執行網頁也沒有問題,
但看到這一堆錯誤訊息,就覺得心浮氣躁,十分不爽快!
若改 Code 途中,真的不小心寫錯而發生錯誤,
還得在一塊 error 海中找到真正的錯誤訊息,
感到十分苦惱!

終於在 microsoft typescript github 找到相關的討論串
裡面有提到未來會修正此問題,也有 workaround,
這邊就說明一下 workaround 步驟:
  1. 下載這個檔案:typescriptServices.js
  2. 找到這個檔案:C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TypeScript\typescriptServices.js
  3. 覆蓋步驟 2 的檔案,重啟 VS2015 即可
暫時這樣的方式解決吧!

2016年5月13日 星期五

VS2015 TypeScript "Compile On Save" options is disabled!

在 Improved support for tsconfig.json in Visual Studio 2015 提到 VS2015 已支援 tsconfig.json,
但發現一個問題,在 VS2015 中,我直接對 *.ts 進行儲存,卻不會立即編譯 ts 檔,
必須要 rebuild 專案才會編譯,這也太無法讓人接受了吧!

經一番 google 才發現,原來專案加入 tsconfig.json 後,預設是關閉 compile on save 的,
那該如何設定才能開啟呢?

  1. 找到 VS2015 Tools\Options\Text Editor\TypeScript\Project 頁面
  2. 勾選 "Automatically compile typescript files which are not part of a project"
  3. 重啟 VS2015




2016年5月12日 星期四

Improved support for tsconfig.json in Visual Studio 2015

原來 typescript 1.8 已改善 Visual Studio 2015 支援 tsconfig.json,
在編譯 *.ts 檔時,依 tsconfig.json 的參數進行 ( release note )
( includes ASP.NET v4 projects )

在未支援前,還要直接修改專案檔,如下:

現在只要在專案加入 tsconfig.json ,依需求設定參數即可
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "node_modules",
    "typings/main",
    "typings/main.d.ts"
  ]
}


在專案檔 typescript 參數設定頁面就會被設為不可編輯,如下:


這樣真的就方便多了,不用再煩惱啦!

2016年5月9日 星期一

upgrade angular 2 to RC1 solution ( from beta.17 )

在 2016/05/02 angular2 就已發佈至 RC 0
緊接著在 2016/05/02 又發佈了 RC1 
升級的過程一直不順利,
看來無法跟之前一樣,package 版本的數字改一改就好,
要乖乖看文件了!

終於把問題解決了,大致要處理的部分如下:
  • package module rename
  • typescript typing
  • systemjs.config.js
package module rename
先來看看 change log,在 RC0 做了重大變更,
node_module 資料夾下,angular2 資料夾換成 @angular 當然底下的路徑都換了,
所以要將以下 package 路徑做替換,
詳情如下:
To import various symbols please adjust the paths in the following way:
  • angular2/core -> @angular/core
  • angular2/compiler -> @angular/compiler
  • angular2/common -> @angular/common
  • angular2/platform/browser -> @angular/platform-browser (applications with precompiled templates) + @angular/platform-browser-dynamic (applications that compile templates on the fly)
  • angular2/platform/server -> @angular/platform-server
  • angular2/testing -> @angular/core/testing (it/describe/..) + @angular/compiler/testing (TestComponentBuilder) + @angular/platform-browser/testing
  • angular2/upgrade -> @angular/upgrade
  • angular2/http -> @angular/http
  • angular2/router -> @angular/router-deprecated (snapshot of the component router from beta.17 for backwards compatibility)
  • new package: @angular/router - component router with several breaking changes

typescript typing
接著設定 typescript typing ( 參考 ):
在專案根目錄新增 typings.json 檔案,內容:
{
  "ambientDependencies": {
    "es6-shim": "registry:dt/es6-shim#0.31.2+20160317120654",
    "jasmine": "registry:dt/jasmine#2.2.0+20160412134438"
  }
}

設定 package.json

在 Visual Studio 2015 對 package.json 儲存後,
即會在專案根目錄下,建立 typeings 資料夾,


在 root componment 加入 typings/browser/ambient/es6-shim/index.d.ts reference

systemjs.config.js (參考)

html 頁面使用方式,
<!-- 1. Load libraries -->
<script src="~/node_modules/es6-shim/es6-shim.min.js"></script>
<script src="~/node_modules/zone.js/dist/zone.js"></script>
<script src="~/node_modules/reflect-metadata/Reflect.js"></script>
<script src="~/node_modules/systemjs/dist/system.src.js"></script>

<script type="text/javascript">
    window.filterSystemConfig = function (config) {
        config.baseURL = '@Url.Content("~/")';
    }
</script>

<!-- 2. Configure SystemJS -->
<script src="~/systemjs.config.js"></script>
<script type="text/javascript">
    System.import('PublishScenario')
        .catch(function (err) { console.error(err); });
</script>

其中指定 config.baseURL  為 網站的根目錄
<script type="text/javascript">
    window.filterSystemConfig = function (config) {
        config.baseURL = '@Url.Content("~/")';
    }
</script>

systemjs.config.js 的內容如下:
(function (global) {

    // map tells the System loader where to look for things
    var map = {
        'PublishScenario': 'Scripts/angular-app/PublishScenario', // 'dist',
        'rxjs': 'node_modules/rxjs',
        'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
        '@angular': 'node_modules/@angular',
        'ng2-bs3-modal': 'node_modules/ng2-bs3-modal'
    };

    // packages tells the System loader how to load when no filename
    // and/or no extension
    var packages = {
        'PublishScenario': {
           
            main: 'main.js',
            defaultExtension: 'js'
        },
        'rxjs': { defaultExtension: 'js' },
        'ng2-bs3-modal': { main: 'ng2-bs3-modal.js', defaultExtension: 'js' },
        'angular2-in-memory-web-api': { defaultExtension: 'js' },
    };

    var packageNames = [
      '@angular/common',
      '@angular/compiler',
      '@angular/core',
      '@angular/http',
      '@angular/platform-browser',
      '@angular/platform-browser-dynamic',
      '@angular/router',
      '@angular/router-deprecated',
      '@angular/testing',
      '@angular/upgrade',
    ];

    // add package entries for angular packages in the form 
    // '@angular/common': { main: 'index.js', defaultExtension: 'js' }
    packageNames.forEach(function (pkgName) {
        packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
    });

    var config = {
        map: map,
        packages: packages
    }

    // filterSystemConfig - index.html's chance to modify 
    // config before we register it.
    if (global.filterSystemConfig) { global.filterSystemConfig(config); }

    System.config(config);

})(this);

以上是查看官方文件後,進行的設定,若仍有問題,就到官網去看看吧!

2016年3月29日 星期二

Upgrading NPM in Visual Studio 2015


之前寫過一篇文章 msbuild copy files - Illegal characters in path error
處理 npm 包裝的 package 資料夾結構太深,導致 msbuild 無法複製檔案的問題,
在 npm 3.* 版後,已處理此問題,

可是即使我安裝了新版的 nodejs ,
VS2015 還是使用舊的 npm 版本,
到底該如何處理呢? 接著看下去

在 VS2015 升級 NPM 步驟:
  1. 下載新版的 nodejs stable 版
  2. 在 VS2015, Tools / Options / Projects and Solutions / External Web Tools,
    加入 nodejs 安裝路徑並置頂,如: C:\Program Files\nodejs

  3. 重啟 VS2015,就完工囉!

2016年3月21日 星期一

Error - unable to convert runtime connection string to its design-time equivalent mysql

最近將 web site project  升級至  web application project,
開發環境從 VS2012 升級至 VS2015,

發現在更新 entity framework 的 edmx 檔的物件時發生錯誤:

執行「update model from database」



錯誤訊息: 

unable to convert runtime connection string to its design-time equivalent..


solution:
更新 the visual studio plugin 即可
請至此下載:http://dev.mysql.com/downloads/windows/visualstudio/



安裝完畢後,重啟 VS2015 即可正常更新 entity object