none
Team Build with unsafe code problem

    Dotaz

  • My project has some unsafe code exist that I already marked project "Allow unsafe code" option.  SO I can build it from my machine

    But It cannot build in Team Build Server....the following is error message

    ThemeManager.cs(457,33): error CS0227: Unsafe code may only appear if compiling with /unsafe

    Please help

    20. února 2006 10:05

Odpovědi

  • Thank you for your reply.  I fixed my problem that it is configuration issue that I only checked it in debug mode.  I checked it in release mode that I can build in Team Build.

    But I got another issue that I added the following code in the class.  I can build it in VS.  But I can't build it in Team Build
    Class1.cs(11,22): error CS1012: Too many characters in character literal

            public unsafe void TestMethod()
            {
                char c = '●';
                if (c == '●')
                       return;

            }

    21. února 2006 7:10

Všechny reakce

  • Is the configuration being built in VS and by Team Build same?  The "Allow unsafe code" is per configuration setting and you need to ensure that it is set for all the configurations that Team Build is building.

    Thanks,

    Gautam

    20. února 2006 12:08
  • I only config in VS then I can build it in VS.  But Team Build can't.
    So how can I do?

    20. února 2006 13:12
  • TeamBuild builds the same VS solution using msbuild. So you need not configure team build seperately to compile unsafe code. When you add unsafe code to your solution you typically go to the project properties and in the build tab check "Allow unsafe code". The problem is that this is a per-configuration setting. So you need to ensure for all configurations this is checked. Do the following to ensure this.

    Go to Project -> Properties and then to the Build Tab. Ensure for all Configurations (on the top of this page) the Allow unsafe code check box is checked. If it is not checked for one of the configurations and Team Build is setup to build that configuration then your build will fail with this error.

    20. února 2006 18:26
  • I already done it but I still can't build in Team Build

    I created a sample project and Go to Project -> Properties and then to the Build Tab.  the Allow unsafe code check box is checked.  Then I build it in VS that I can.  So I try to build it in Team Build but it still can't to build it.

    The following is sample project

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace Test
    {
        public class Class1
        {
            public unsafe void TestMethod()
            {
            }

        }
    }

    When I build it in Team Build I got the following error
    Class1.cs(9,28): error CS0227: Unsafe code may only appear if compiling with /unsafe

    21. února 2006 3:50
  • What is the build configuration (Release, Debug or something else) and build platform (Any CPU, x86 etc) that you have choosen for Team Build?  Have you choosen the same setting for build from VS?

    Try doing this on your client machine -

    1) Open a Visual Studio Command Prompt

    2) Go to the location .sln file.

    3) Do "msbuild /p:Configuration=<configuration choosen in Team Build>;Platform=<platform choosen in Team Build>  MySolution.sln

    Does this pass?

    Thanks,

    Gautam

    21. února 2006 6:18
  • I just tried this code sample and I am able to build it through TeamBuild. So it may be a configuration issue.

    What Gautam and I are suggesting is change the Configuration on top of that Build page and cycle through all configurations like Debug, Release and ensure that the check box is checked for all of them.  Or you can just change the configuration to All Configurations and then ensure that the checkbox is checked.

    If this is not done correctly then the option is set for some configuration and not for some other configuration. If you are building one of these other configuration through TeamBuild then build will fail.


    21. února 2006 6:24
  • Thank you for your reply.  I fixed my problem that it is configuration issue that I only checked it in debug mode.  I checked it in release mode that I can build in Team Build.

    But I got another issue that I added the following code in the class.  I can build it in VS.  But I can't build it in Team Build
    Class1.cs(11,22): error CS1012: Too many characters in character literal

            public unsafe void TestMethod()
            {
                char c = '●';
                if (c == '●')
                       return;

            }

    21. února 2006 7:10
  • What does line 11 column 22 corresponds to?  I guess it corresponds to the unicode char.

    Check for the following -

    1) The file is saved properly in Unicode setting.

    2) On build machine, you are able to compile it using msbuild command line mentioned earlier.

    Thanks,

    Gautam

    21. února 2006 10:08