Turn off MSBuild support for TypeScript compilation

Is there a way to prevent TypeScript files from compiling during build/debug in Visual Studio projects like ASP.NET MVC5?

I have already set tsconfig.json properties compileOnSave and buildOnSave to false. Do I need to add anything to the project's .csproj file to ensure TypeScript files are not compiled?

While debugging the ASP.NET MVC5 project, it automatically compiles all .ts files.

Any assistance on this matter would be greatly appreciated. Thank you!

Answer №1

In order to disable MSBuild based TypeScript compilation, you can follow the instructions provided here. Simply add the property

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
to a PropertyGroup in your csproj file, specifically under the Configuration label.

By enabling this setting, there should be no need for tsconfig.json settings related to compileOnSave/buildOnSave.

If you are using an older version of Visual Studio (such as VS 2017 or xproj with 2015), you may find the property as

<TypeScriptEnabled>false</TypeScriptEnabled>
.

Answer №2

Despite having everything configured, the issue persisted in my Visual Studio 2019 environment. In an attempt to resolve it, I included the following additional code:

 <TypeScriptCompileOnSaveEnabled>False</TypeScriptCompileOnSaveEnabled>

After restarting Visual Studio, the problem was finally resolved for me.

Answer №3

After trying various solutions without success, I encountered an error when attempting to load the project (using VS 2019 - version 16.9.4).

<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>  // did not resolve my issue

Alternatively, you can achieve the same result with minimal additional effort by excluding all TypeScript files from the compilation index.

<TypeScriptCompile Remove="*" />

This approach has been helpful for me in preventing the compilation of certain directories, such as node modules:

<TypeScriptCompile Remove="node_modules\**" />

Answer №4

In my experience with Visual Studio 2015, I found that including the following line in the PropertyGroup section resolved my issue.

<DisableTypeScriptCompilation>true</DisableTypeScriptCompilation>

Answer №5

Despite trying all the suggestions provided here, I couldn't resolve the issue,

However, as soon as I included the following line, everything started working smoothly:

<JavaScriptLibrariesVersion>2.5</JavaScriptLibrariesVersion>

It appears that the previous version I was using wasn't compiling properly regardless of the settings.

Answer №7

Perhaps this information could be beneficial to others:

What I noticed in Visual Studio 2022 is that certain properties, including others, seem to be disregarded when navigating to Tools -> Environment -> Preview Features -> Use previews of .NET SDK (requires restart) is set to on

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Strange ASP.NET Redirection/Submission Problem

My code is enclosed in a try/catch block with a redirect to another page, but I'm encountering a problem. When a user clicks on a submit button, instead of redirecting to the intended page, the page simply refreshes and stays on the same page. This is ...

Creating a unique object by dynamically incorporating features from another object

I've recently implemented a tree structure in my UI using Material Tree, and it requires creating a new object to represent the tree. The initial object format is as follows: [ { name: 'Fruit', children: [ {name: 'Apple& ...

Tips for effectively unit testing the Angular @viewChild directive with ElementRef

In my component file, I have the following code snippet @ViewChild('clusterCard', { static: false }) clusterCard: ElementRef; highLightTheClusterCard(point: PickupClusterPoint) { if (point) { const card: HTMLElement = _get(this.cluster ...

How can I identify and remove duplicate file names using asp:fileupload?

Within my UpdatePanel, I have an ASP:FileUpload in the ContentTemplate. I need to check the filename against the database before proceeding. While I know how to handle the database part, I am unsure of how to call a server-side function for ASP:FileUpload ...

Angular and Bootstrap project with an advanced dropdown menu featuring multiple levels

Looking to create a multi-level drop-down menu using TypeScript without relying on jQuery? Bootstrap CSS framework may not have exactly what you need. https://i.sstatic.net/iruev.png Wondering how to implement a multi-level dropdown in your Angular proje ...

Is it possible to implement COM in ASP.NET without registration?

Utilizing a COM object in Windows doesn't require registering the COM dll. Instead, you can include a special "dependent assembly" in your application's manifest: MyProgram.exe.manifest <?xml version="1.0" encoding="utf-8" standalone="yes" ...

What is the best way to incorporate delete buttons for clearing the entire state and removing specific states generated by the .map function?

I attempted to initialize the array to clear all elements inside of it, however, it was not successful. clearAll(){ this.setState({ posts: [] }) } componentDidMount() { axios.get('https://jsonplaceholder.typicode.com/posts') ...

Guide on dynamically applying a CSS rule to an HTML element using programming techniques

Currently working with Angular 6 and Typescript, I am facing a unique challenge. My task involves adding a specific CSS rule to the host of a component that I am currently developing. Unfortunately, applying this rule systematically is not an option. Inste ...

Getting the elements from a List using a lambda expression, bypassing the need for a for loop or foreach method

I need to pass an entity as a parameter to a method without using for or foreach loops. Is there a way to achieve this using lambda expressions? Below is my code snippet: private async Task SaveParents() { try { await Task.Run(() => { ...

Contrast the functionalities of DataTables and determine when to update one based on

I have a dilemma with two DataTables: one is generated from a csv file and the other comes from a DB table. https://i.sstatic.net/4EFZs.png How can I compare both DataTables by id and name? If a record exists in the DataTableFromFile but not in ...

Perform an HTTP GET request to a RESTful service with specified parameters using Angular 2

I'm currently facing an issue while attempting to create a GET request to the YouTube Web API. I'm struggling with passing parameters through the http.get function and have confirmed the request is being sent using Fiddler. However, I keep receiv ...

Leveraging TypeScript generics for indexing

Trying to establish type information for event listeners by using generics on the .on() function. type Name = "error" | "connected"; type Callback = { error: (err: Error) => void, connected: (err: number) => void, }; function on<T exten ...

Struggling to use the bind method for the loadScene callback function in cocosCreator or cocos2d-x?

When the loadScene() callback function is bound, the information retrieved from getScene() becomes inaccurate. Upon transitioning from the Entry Scene to the Lobby Scene, I perform post-processing tasks. The implementation was done in TypeScript. Entry. ...

What is the process for integrating TypeScript compiling into a JavaScript application?

My project includes a build.js file that is responsible for building the project. It has two main objectives: Compile .ts files and store them in a new directory. Create an asar archive containing the compiled files. Since typescript (or tsc) is availabl ...

Passing asynchronous data from method1 to method2 without impacting the functionality of the script responsible for fetching the asynchronous data in method1

When working with TypeScript, I encountered an issue while trying to invoke an external script called SPCalendarPro within a private method that asynchronously fetches data. The script is invoked in the following manner: private _getSPCalendarPro() { con ...

Apollo GraphQL Server is unable to provide data to Angular

I've been facing a challenge for quite some time now trying to make my Angular component communicate with an Apollo GraphQL server using a simple Query (PingGQLService). I'm currently utilizing apollo-angular 4.1.0 and @apollo/client 3.0.0, and h ...

ASP.NET UserControls do not support JavaScript functionality

Within 'MyFirstControl', there lies a control. In an effort to simplify my question, I added an alert('test') which unfortunately does not appear. Despite stripping away all other functions in my JavaScript and keeping only this alert ...

Bringing together a collection of objects connected by shared array elements

Given the types defined as: type A = { commonKey: { a: string }[] }; type B = { commonKey: { b: number }[] }; Is it possible to create the type below without explicitly specifying commonKey? type C = { commonKey: { a: string, b: number }[] } My initial a ...

The status of the Mat-checkbox is determined by the response from the modal dialog

In my project, I have a list of users stored in an array. Using HTML, I utilized the *ngFor directive to create a checkbox for each user element. Additionally, there is an @Input assignedAccountIds[] which contains the IDs of default selected users. The c ...

How do I implement an array of objects using an interface in React and Typescript?

I'm working with an array of objects where the data is stored in a JSON file. Here's a glimpse of the JSON file: [ { "_id": "62bd5fba34a8f1c90303055c", "index": 0, "email": "<a href="/cdn-cgi/l/emai ...