How to tell Visual Studio to build .cu files

How can I tell visual studio that it should rebuild the .cu Files that have changed when I do a “Build Solution” in Visual studio? So far, Visual Studio does not recognize file changes in the .cu files and therefore does not rebuild them. (Currently I’m doing it by hand in the solution explorer, which is not very comfortable)

Did you add the source file (.cu) to the project and add a custom build rule for .cu types. It works in my project.

here is my cuda.rules file (part of it)

<?xml version="1.0" encoding="utf-8"?>


Name="CUDA Compile"






		DisplayName="CUDA Compile"

		CommandLine="$(CUDA_BIN_PATH)\nvcc.exe -ccbin &quot;$(VCInstallDir)bin&quot; -c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/RTC1,/MTd -I&quot;$(CUDA_INC_PATH)&quot; -I./ -I/cuda/sdk/common/inc -o $(InputName)  $(InputFileName)"



		ExecutionDescription="Executing tool..."






I have only a debug rule set (not emu) but those could be easily added.

Hope that helps


I added the .cu file to the project and added a custom build rule for this file via the properties page (But I think that this is only a build rule for this file, not for .cu files in general).

How did you create your cuda.rules File? The rule I added is in my .vcproj File, not in a separate file.

Check this thread:

I can’t add any *.cu files to my project by right clicking on visual studio, then add, then some .cu file. If the file is, I get an error saying “The desired name for is invalid” in visual studio. How would I do this any other way?