Build error "Cannot find name 'Record'" with bootstrap 4 - visual-studio

Today, I decided to migrate my ASP .NET MVC 5 project from bootstrap 3 to bootstrap 4 (the sass version).
After the migration, I got an error after the compilation of my project.
Error Build:Cannot find name 'Record'.
Error Build:Cannot find name 'undefined'.
How to solve this?

After some research, I found this link to have a better understanding of typescript and visual studio. If you want to improve your skills, you can go to this official page and have some readings.
The solution
You just have to update the typescript plugin for Visual studio. You can download the latest version here for visual studio 2015.
Here for visual studio 2017
Enjoy!

If, for some reason you are unable to update your Visual Studio with the updated TypeScript .exe file (company/business IT policy, non-admin account, etc...), you can try this solution:
Single-click on the "index.d.ts" file in Visual Studio Solution Explorer.
Look in the Properties panel, under "Build Action".
Switch it from "TypeScriptCompile" to "Content".
Now, you'll be able to build your project without these errors.
Update 2019
I have found another workaround/solution that hasn't had any noticeable effects and still allows me to compile without erroring on index.d.ts. Just comment line 68 in your index.d.ts file as such:
//[name: string]: (BaseModifier & Record<string, any>) | undefined;

For Visual Studio 2015:
I downloaded TypeScript, installed and restarted Visual Studio. While restarting it prompted me the TypeScript my solution uses is older than what is installed(2.9.2) and whether I want to update it to the supported version, I clicked Yes and that fixed the issue.
My guess is TypeScript 2.9.2 is for VS 2017 maybe.

I uninstalled jpopper.cs and went to the Web.config file and added these lines of code
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
to deal with that validation error.

Out of the box, for me it has been fixed by update VS 17 to latest version!!

open your project in visual studio 2017 and it will ask you to upgrade the typescript just press upgrade
OR
Upgrade your Typescript version

Related

VS 2019 could not find SDK

I keep getting this error, I am trying to perform the unity MRTK tutorial for hololens 2. I did everything on the first page https://learn.microsoft.com/en-us/windows/mixed-reality/mr-learning-base-02. When I try and run it this error comes up. I have tried to install 10.0.19041.0 through windows but it always kicks to 19041.1 I have installed all the required components in visual studio.
Any help would be appreciated.
Error pic
Installed Vs individual components
Unity Build settings
The problem you met is a bug seemingly caused by vs installer. It happens when Visual Studio is not installed on driver C.
You can see it here:
https://developercommunity2.visualstudio.com/t/HoloLens-2-build-fails-if-Windows-sdk-is/1313568
There are many ways you could do to get through this.
Copy the folder [Windows Kit Root Dir]\10\Extension SDKs\WindowsMobile (For e.g., D:\Windows Kits\10\Extension SDKs\WindowsMobile) to C:\Program Files (x86)\Windows Kits\10\Extension SDKs\. Should solve all of the missing WindowMobile issues.
https://developercommunity.visualstudio.com/t/msb3774-could-not-find-sdk-windowsmobile-version10/402362#T-N474809
Delete the reference to the Mobile SDK in the vxcproj file.
https://stackoverflow.com/a/60600054/9522354
I tried the first method and it worked for me.
I have tried to install 10.0.19041.0 through windows but it always kicks to 19041.1
For how to modify the SDKReference version, you can try following step:
By referring Section 5 of Update your C#/VB projects to use the latest Universal Windows Platform
Right-click your existing project(YourProjectName(Universal Windows)) in solution explorer, then select Unload Project. After the project is unloaded, right-click the project file again and choose to edit the .vcxproj file.
Find "SDKReference" element and change the value of version from "10.0.19041.1" to your version like "10.0.19041.0".
<ItemGroup>
<SDKReference Include="WindowsMobile, Version=10.0.19041.1" />
</ItemGroup>
to
<ItemGroup>
<SDKReference Include="WindowsMobile, Version=10.0.19041.0" />
</ItemGroup>
Besides, since you are using HoloLens2, it is recommended to set the Architecture in the Unity Build Setting window to x64.

TypeScript VsTsc error in Visual Studio 2017

I'm testing migration from VS 2015 to VS 2017 for a .NET Core / TypeScript project.
The build fails in VS 2017 with this error in Microsoft.TypeScript.targets:
MSB4064 The "PreferredUILang" parameter is not supported by the "VsTsc" task. Verify the parameter exists on the task, and it is a settable public instance property.
The version of TypeScript in VS 2017 is 2.1.5, however, I have already installed the 2.2.1 SDK for Visual Studio 2015.
I've also noted that there is no 2.2+ SDK release for Visual Studio 2017 yet.
Could this be causing conflicts? Is this something I can resolve now or do I need to wait for an update to the TypeScript SDK for VS 2017 to reach 2.2.1+?
Any help in this area appreciated!
This might be a bit of crude solution to the problem but we simply went through the "Microsoft.TypeScript.targets" file and removed PreferredUILang="$(PreferredUILang)" from any <VsTsc ... > nodes, we had a look into the Typescript task dll and it seems that it does not have a PreferredUILang property.
It is possible that the task once upon a time did have such a property but was removed and Microsoft have forgotten to update the targets file, I'm not sure but this seems to be working for us at least.
Please make sure you backup your "Microsoft.TypeScript.targets" file before editing.
I have same problem here in VS2015 Update 3 and I also fixed the Microsoft.TypeScript.targets, as suggested by ginja, but as I don't like to hack the nuget packages I went deeper in the issue.
The real problem is that when you add/upgrade the typescript nuget package, you have to manually remove the imports to the machine-wide targets and props. having both leads to unknown load order or targets/tasks, which would manifest in such errors.
So the approach I used is:
Uninstall from the project the nuget packages "Microsoft.TypeScript.Compiler" and Microsoft.Typescript.MSBuild"
Close VS (to guarantee the real clean of such package)
Edit you .csproj file commenting out the imports to the machine-wide targets and props: (all <Import Project="$(MSBuildExtensionsPath32)\Microsoft\...
Restart VS, open the project and add again the nuget packages for Typescript. This point correctly updates your .csproj with the correct imports and configuration of the TypeScript compiler.
Just for a clean safe: restart VS.
removing following lines from CSPROJ solved problem for me
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\WebApplications\Microsoft.WebApplication.targets')" />
to edit csproj file
Right click the project in Solution Explorer.
Select "Unload project"
Project is now unloaded.
Right click the project again and select
"Edit blah.csproj"
Make your changes and save them.

Typescript build failure

I'm currently having two projects with typescript 1.1 that are opened in visual studio 2013 with typescript 1.8 installed. VS asks to upgrade which I did but now I get the following error:
Unknown compiler option 'listemittedfiles'.
Anyone has had the same?
It seems inside the project we had this line hardcoded
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" />
That way even though it was upgraded to 1.8 it still tried to use w/e was installed in that folder.
(This is a very old project that needs maintenance...)
Next to that I've removed the hardcoded path in the Path system environment variables so that tsc.exe now points to the NPM version.
If the above answer doesn't work for you, I suggest to take a look to this other answer which addressed that same issue on Visual Studio 2015 Update 3 and above:
(to summarize it, installing TypeScript 2.0 from this official link might fix the messed-up MSBuild cfg and solve the issue).

Visual Studio 2013 Update 4 has broken web templates

After installing Update 4 on my Desktop workstation and laptop computers, both of them have lost the web templates.
When I try to create a new C# web project I only can see this:
And If I select it, then I can see this error:
I write the error message here to future search:
Error: this template attempted to load component assembly
'Microsoft.VisualStudio.Web.Project, Version=2.3.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'. For more information on this
problem and how to enable this template, please see documentation
on Customizing Project Templates.
Any idea how can I recover this templates?
I had this issue! Did a 'Repair' and it's now fixed!
To repair, go to Control Panel/Uninstall a program/View installed updates/Uninstall/Repair.
Check if All the templates are present in the given directories
"Visual Studio installation path"\Common7\IDE\ProjectTemplates\
"Visual Studio installation path"\Common7\IDE\ItemTemplates\
then Open command with administrator navigate to "Visual Studio installation path"\Common7\IDE\" and Type devenv.exe /InstallVSTemplates
If this doesn't Help Reinstalling definitely will

MSBuild Errors while building VSTO Addin's

I recently migrated my VSTO Add in projects from "VS2008 and office 2007" to "VS2013 and office 2013", Changes took place as below settings.
.Net Framework version from 3.5 to 4.5(While upgrading project).
I have added VSTO 2013 PIA assemblies to reference.
That's it, when i tried to compile i have faced below MSBuild errors.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(268,13): error MSB4064: The "TargetFrameworkVersion" parameter is not supported by the "SignFile" task. Verify the parameter exists on the task, and it is a settable public instance property.
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets(264,9): error MSB4063: The "SignFile" task could not be initialized with its input parameters.
and i have tried to find solutions over the internet but couldn't find much, Any Solutions for this problem will be helpful.
The problem was not the MSBuild, **
i have updated visual studio update 3 to update 4
and started working like charm.
I think Microsoft guys have moved something around from Update 3 to update 4 but this has been reported several times in many forums and i don't know why they have not mentioned it but this is one effective solution.
I ran into this issue. The problem is that Update 3 of Visual Studio 2013 moved some things around, so you need to use the MSBuild that is now installed with Visual Studio 2013 (or the standalone build tools for build servers). You need to make sure that you're using the correct MSBuild (currently at C:\Program Files (x86)\MSBuild\12.0\Bin), and it should work.
http://datatoknowledge.com/2015/01/30/vsto-and-visual-studio-2013-update-3/
Erick
This is still not working as of Visual Studio 2015 Update 3.
I had to actually modify the C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets file and remove the TargetFrameworkVersion attribute from the SignFile task.

Resources