问题
I'm trying to migrate some javascript files to Typescript in a legacy ASP.NET MVC 5 project. I I've created a Typescript file and the compilation from TS to JS works as expected, but I there is no "Typescript Build" Tab in my legacy project's properties.
I did not have this problem when working on a new ASP.NET MVC 5 project. How can I fix this in my legacy project? I am using Visual Studio 2013 Update 1.
Thanks,
Adrian
回答1:
I needed to add the following line to the csproj to import the typescript targets:
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
Then I could see the typescript build options in the project settings.
回答2:
As Hans Passant correctly hinted in the comments, the problem was the following ProjectGuid in my .csproj file: {349c5851-65df-11da-9384-00065b846f21}
Once I removed that GUID from my project file and reloaded my project, the Typescript tab showed up in the project properties.
回答3:
I have added "TypeScriptToolsVersion" in csproj.
<Project>
<PropertyGroup>
...
<TypeScriptToolsVersion>1.0</TypeScriptToolsVersion>
</PropertyGroup>
</Project>
But it is Visual Studio 2013 RC2.
回答4:
Another possible cause of this is having an old Visual Studio version number in the VisualStudioVersion
node in the .csproj file:
For VS 2013 it should be:
<VisualStudioVersion>12.0</VisualStudioVersion>
For VS 2015 it should be:
<VisualStudioVersion>14.0</VisualStudioVersion>
For VS 2017 it should be:
<VisualStudioVersion>15.0</VisualStudioVersion>
回答5:
I'm not sure about 2013, but for VS2015, you just need to add a TypeScript file to the root folder of the project and it will popup a dialog asking you if you want to configure the project for TypeScript. Simple!
回答6:
To ensure you get the correct settings in your Visual Studio project file:
Add a temp.ts file to your project via Visual Studio and save it (you may get a dialogue about Visual Studio looking up TypeScript types)
Your project file should have updated. Save it.
Close the solution and re-open it.
TypeScript Build Tab should be in the project properties.
Delete the temp.ts file.
(I derived this from Eric D. Johnson's comment here):
https://developercommunity.visualstudio.com/content/problem/98916/typescript-build-tab-not-showing-in-project-proper.html
回答7:
If your csproj has
Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersi>on)\TypeScript\Microsoft.TypeScript.targets" >Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualS>tudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
and still you have issue.
Do the below things:
- Add a new typescript file in the project.
- Build the solution.
- Close and start the Visual Studio, Open the project.
- Check the Typescript Tab in the project properties.
来源:https://stackoverflow.com/questions/23130665/why-is-the-typescript-settings-tab-missing-in-my-vs-2013-asp-net-project-propert