locked
Targets and Rules Files RRS feed

  • Question

  • Hi

    I'm testing VS10 and with the recent launch of nVidia CUDA SDK with support for OpenCL I take a chance to join the two.

    All working fine, just noticed that nvcc custom build step are .rules and VS10 ask for .targets when looking for add external build rule.

    Is there a way to force .rules file in VS10, or a blog I can read about to make a .targets from a .rules?

    Thanks in advance.

    Monday, October 5, 2009 2:39 PM

All replies

  • Hello,

    .rules is the file format used by Custom Build Rules in previous VS releases (VS2005 and VS2008). In VS2010, Custom Build Rules are superseeded by a more general extensibility point named Build Customizations. Build customizations are represented by at least one .targets file (generally a set of .props+.targets+.xml with the same name).

    To ease the migration to the new VS2010 format, the solution conversion will transform any referenced .rules files in their equivalent .props/.targets/.xml: if you go throught the conversion process with any VS2008 project that uses the cuda.rules, after conversion you should see in the same folder with cuda.rules the new cuda.props, cuda.targets and cuda.xml

    You can then use these files in other C++ projects as well, by right clicking on a project node in Solution Explorer, select Build Customization, click "Find Existing" and open the cuda.targets file.

    Hope this helps,
    Marian Luparu
    Visual C++
    Thursday, October 15, 2009 9:21 PM
    Moderator
  • Hello, I want to know if the conversion works ?

    In my practise, there are build errors:

    1>------ Build started: Project: GPU_INFO, Configuration: Release x64 ------
    1>Build started 2009/10/26 12:46:47.
    1>_PrepareForBuild:
    1>  Creating "x64\Release\GPU_INFO.unsuccessfulbuild" because "AlwaysCreate" was specified.
    1>_CUDA_Build_Rule:
    1>  Compiling with CUDA Build Rule...
    1>C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA CUDA SDK\common\Cuda.targets(44,5): error MSB3686: Unable to create Xaml task.  Compilation failed. 
    1>C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA CUDA SDK\common\Cuda.targets(44,5): error MSB3686: Unrecognized escape sequence
    1>C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA CUDA SDK\common\Cuda.targets(44,5): error MSB3686: Unrecognized escape sequence
    1>C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA CUDA SDK\common\Cuda.targets(44,5): error MSB3686: Unrecognized escape sequence
    1>C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA CUDA SDK\common\Cuda.targets(44,5): error MSB3686: Unrecognized escape sequence
    1>C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA CUDA SDK\common\Cuda.targets(44,5): error MSB3686: Unrecognized escape sequence
    1>C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA CUDA SDK\common\Cuda.targets(44,5): error MSB3686:
    1>C:\Documents and Settings\All Users\Application Data\NVIDIA Corporation\NVIDIA CUDA SDK\common\Cuda.targets(44,5): error MSB4036: The "CUDA_Build_Rule" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "D:\Windows\Microsoft.NET\Framework\v4.0.21006" directory.
    1>
    1>Build FAILED.
    Monday, October 26, 2009 4:54 AM
  • maybe sth i did wrong, it works now.

    thanks!!
    Monday, October 26, 2009 6:23 AM
  • The rules conversion is still being worked on.  If you could submit a connect issue, we can address the conversion case directly.

    Thanks.
    Tuesday, November 10, 2009 12:33 AM
  • i made a mistake. it does Not work.

    in the case i test, it only use some cuda api's for detecting information, so the compiler is CLcompile, not nvcc.

    when i use __global functions, the error occurs again. so i don't think the conversion is useful...
    Wednesday, November 11, 2009 7:04 AM

  • You might find this useful to hold you over. It's a set of modified custom build rules that use allow you to have a CUDA project in VS 2010 but compiles the CU code using the VS 2008 compiler.

    http://www.ademiller.com/blogs/tech/2010/08/getting-cuda-3-1-working-with-visual-studio-2010/


    Ade
    Wednesday, September 1, 2010 8:00 AM
  • Hi,

     

     I get a following warning while conversion of my project_name.vcproj

     

    Tool name 'CUDA Build Rule' is not supported in this version and it was renamed as 'CUDA_Build_Rule'.

     

    And after rebuilding I get..

    1>X:\DB_Projects\GPU-EI\10.Software\ncc_only\cuda_sdk\C\common\Cuda.targets(45,5): error MSB3721: The command "echo "$(CUDA_BIN_PATH)\nvcc.exe"   -m 32 -arch sm_10 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"    -Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MTd  " -I"C:\CUDA\include" -maxrregcount=32  --compile -o "$(IntDir)\$(InputName).cu.obj" "X:\DB_Projects\GPU-EI\10.Software\ncc_only\ncc-vc_2010\dynamic_program.cu"

    1>X:\DB_Projects\GPU-EI\10.Software\ncc_only\cuda_sdk\C\common\Cuda.targets(45,5): error MSB3721:  "$(CUDA_BIN_PATH)\nvcc.exe"   -m 32 -arch sm_10 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"    -Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MTd  " -I"C:\CUDA\include" -maxrregcount=32  --compile -o "$(IntDir)\$(InputName).cu.obj" "X:\DB_Projects\GPU-EI\10.Software\ncc_only\ncc-vc_2010\dynamic_program.cu"" exited with code 1.

    Wednesday, September 22, 2010 6:18 AM
  • If looks like MACROs such as $(CUDA_BIN_PATH), $(IntDir), $(InputName) are not expanded. You may to take a look of this blog: http://blogs.msdn.com/b/vcblog/archive/2010/04/21/quick-help-on-vs2010-custom-build-rule.aspx to see the limitation of MSBuild with expanding environment variables and how to solve the problem. You can also take a look of this post: http://social.msdn.microsoft.com/Forums/en/vcprerelease/thread/d24cba9c-ec87-4e27-83c2-1343a2e62a40 on the modified converted CUDA rule files.

    One major limitation is that MSBuild does not support expanding environment variables if they are part of the switches when generating tasks. Take the CUDA rule, for example. You have the following in your original rule file:

    <EnumProperty

         Name="NvccCompilation"

         DisplayName="NVCC Compilation Type"

         Description="Select desired output of NVCC compilation (-c/-compile, -cuda, -gpu, -cubin, -ptx)"

         >

      <Values>

        <EnumValue

         Value="0"

         Switch="--compile -o &quot;$(IntDir)\$(InputName).cu.obj&quot;"

         DisplayName="Generate hybrid object file  (--compile / -c)"

          />

        <EnumValue

         Value="1"

         Switch="-cuda -o &quot;$(IntDir)\$(InputName).cu.c&quot;"

         DisplayName="Generate hybrid .c file  (-cuda)"

          />

        />

     

    They will be converted into:

    <EnumProperty

          Name="NvccCompilation"

          HelpContext="0"

          DisplayName="NVCC Compilation Type"

          Description="Select desired output of NVCC compilation (-c/-compile, -cuda, -gpu, -cubin, -ptx)">

      <EnumValue

        Name="0"

        DisplayName="Generate hybrid object file  (--compile / -c)"

        Switch="--compile -o &quot;$(IntDir)\$(InputName).cu.obj&quot;" />

      <EnumValue

        Name="1"

        DisplayName="Generate hybrid .c file  (-cuda)"

        Switch="-cuda -o &quot;$(IntDir)\$(InputName).cu.c&quot;" />

    </EnumProperty>

     

    The $(IntDir) and $(IntputName), however, will not be expanded during compile due to the limitation of the task generated by the task generator. As a result, you will see the following command line that $(IntDir) and $(InputName) are not expanded.

    -arch sm_10 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"    -Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MT  " -I -maxrregcount=32  --compile -o "$(IntDir)\$(InputName).cu.obj" "C:\cuda\cuda\cuda2.cu"

     

    To work around this, you need to redefine the value in the converted targets file as follows:

     

    <ItemGroup>

      <CUDA_Build_Rule Condition="'%(CUDA_Build_Rule.NvccCompilation)' == '0'">

        <NvccCompilation>-c -o &quot;$(IntDir)\%(Filename).cu.obj&quot;</NvccCompilation>

      </CUDA_Build_Rule>

      <CUDA_Build_Rule Condition="'%(CUDA_Build_Rule.NvccCompilation)' == '1'">

        <NvccCompilation>-cuda -o &quot;$(IntDir)\%(Filename).cu.c&quot;</NvccCompilation>

      </ItemGroup>

     

    Li Shao, MSFT


    Li Shao
    Friday, September 24, 2010 6:26 PM
  • Hi,

     

     So I could invoke the compiler, but I am getting the following

    nvcc fatal   : nvcc cannot find a supported cl version. Only MSVC 8.0 and MSVC 9.0 are supported

    I got it on cmd.exe, the commandline parameters, I copied from below.

    I got a weird error on VS2010

     

    1>X:\DB_Projects\GPU-EI\10.Software\ncc_only\cuda_sdk\C\common\Cuda.targets(76,5): error MSB3721: The command "
    1>X:\DB_Projects\GPU-EI\10.Software\ncc_only\cuda_sdk\C\common\Cuda.targets(76,5): error MSB3721:         echo C:\CUDA\bin64\nvcc.exe   -m 32 -arch sm_10 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"    -Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MTd  " -IC:\CUDA\include -maxrregcount=32  -c -o "Debug\\dynamic_program.cu.obj" "X:\DB_Projects\GPU-EI\10.Software\ncc_only\ncc-vc_32bit_2010\dynamic_program.cu"
    1>X:\DB_Projects\GPU-EI\10.Software\ncc_only\cuda_sdk\C\common\Cuda.targets(76,5): error MSB3721:         C:\CUDA\bin64\nvcc.exe   -m 32 -arch sm_10 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin"    -Xcompiler "/EHsc /W3 /nologo /O2 /Zi   /MTd  " -IC:\CUDA\include -maxrregcount=32  -c -o "Debug\\dynamic_program.cu.obj" "X:\DB_Projects\GPU-EI\10.Software\ncc_only\ncc-vc_32bit_2010\dynamic_program.cu"
    1>X:\DB_Projects\GPU-EI\10.Software\ncc_only\cuda_sdk\C\common\Cuda.targets(76,5): error MSB3721:       " exited with code -1.
    ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

     

    Nishkant

     

    Thursday, September 30, 2010 8:21 PM
  • To ease the migration to the new VS2010 format, the solution conversion will transform any referenced .rules files in their equivalent .props/.targets/.xml: if you go throught the conversion process with any VS2008 project that uses the cuda.rules, after conversion you should see in the same folder with cuda.rules the new cuda.props, cuda.targets and cuda.xml

    I'm trying to import a project which is using a custom rcxgettext.rules file from VC9 into VC10. However, VC10 keeps reporting:

    The imported project "C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\rcxgettext.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

    I even used the Process Monitor utility to discover that VC10 is not trying to load the rcxgettext.rules file at all. It tries to load the rcxgettext.props and rcxgettext.targets files only. How is it supposed to convert the .rules file to .props/.targets/.xml if it doesn't even touch it?

    I am running a clean instalation of VC10 (10.0.30319.1) with elevated privileges on a freshly installed Windows 7 Ultimate 64-bit with all the updates installed.

    • Edited by Rozi Thursday, December 30, 2010 11:26 AM grammar
    Thursday, December 30, 2010 11:24 AM
  • I suspect this is because your .vcproj file currently refers to the .rules files in a <DefaultRule> tag rather than a <Rule> tag.

    By default, when adding rules to a project using the VS2005/VS2008 UI you should always end up in your project with a <Rule> tag that points to the path to the .rules files. Usually <DefaultRule> tag is used for system rules (shipping with VS) and don't specify a path but only the name of the rule and special look-up logic is used to find them in the VS installation folder.

    Now, during conversion in VS2010, we also treat <DefaultRule> tags differently. Because we already ship converted rules files (in the form of .props/.targets./.xml) for these, we don't attempt to reconvert them but just to fix the path for them to the new location (C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations).

    You can fix this by either changing your projects to have the <Rule> tag with a full path rather than <DefaultRule>. Alternatively, you can just fix one project, do the conversion and then copy the generated .props/.targets/.xml to the location VS expects to find them (C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations) and continue converting the rest of your projects.

    Hope this helps,
    Marian Luparu
    Visual C++

    • Proposed as answer by Rozi Friday, December 31, 2010 9:07 AM
    Thursday, December 30, 2010 7:55 PM
    Moderator
  • Thank you Marian. You were right. I did have my .rules file in the $(VCInstallDir)VCProjectDefaults folder. Majority of our projects are using this common .rules file. Storing it in $(VCInstallDir)VCProjectDefaults folder made deployment of development environment easier.

    Anyway, I did fix just one project, converted the project to VS2010 and moved the newly generated .props/.targets/.xml file to BuildCustomizations folder.

    Best regards,
    Simon

    Friday, December 31, 2010 9:13 AM