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"?>

<VisualStudioToolFile

Name="CUDA Compile"

Version="8.00"

>

<Rules>

	<CustomBuildRule

		Name="CUDA"

		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)"

		Outputs="$(InputName).obj"

		FileExtensions="*.cu"

		ExecutionDescription="Executing tool..."

		>

		<Properties>

		</Properties>

	</CustomBuildRule>

</Rules>

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

Hope that helps

-Jan

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: http://forums.nvidia.com/index.php?showtopic=30273

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 xx.cu, I get an error saying “The desired name for xx.cu is invalid” in visual studio. How would I do this any other way?