2017-03-21 13 views
14

मेरे पास एक प्रोजेक्ट है कि फ्रेमवर्क .NET Framework 4.6.1 को लक्षित करता है, टीएफएस पर निरंतर एकीकरण प्रक्रिया के हिस्से के रूप में हमने एक बिल्ड समाधान कार्य बनाया है ताकि यह सुनिश्चित किया जा सके कि कोड सही ढंग से संकलित करता है।
अब टीएफएस सर्वर में .Net Famework 4.6.2 का नवीनतम संस्करण है। रजिस्टर पर इस ढांचे

On all other OS versions: 394806 => .NET Framework 4.6.2

लेकिन जारी कुंजी के लिए मूल्य है, जब निर्माण यह इस त्रुटि के साथ आता है चलाता है:

Error CS1056: Unexpected character '$' 

मैं के साथ स्ट्रिंग प्रक्षेप को बदलने के लिए नहीं करना चाहते हैं इस समस्या को हल करने के लिए string.Format, कृपया इसे हल करने के लिए एक और कार्य प्रदान करें।

क्या मुझे टीएफएस सर्वर पर कुछ और स्थापित करने की आवश्यकता है?

+0

सर्वर पर MSBuild का कौन सा संस्करण चल रहा है? –

+0

आपको 'MSBuild' उपकरण को अपडेट करने की आवश्यकता है, न कि '.NET' फ्रेमवर्क – VMAtm

+0

@VMAtm मैं यह कैसे कर सकता हूं? मैंने अभी https://www.microsoft.com/en-us/download/details.aspx?id=48159 डाउनलोड किया है और वह वह है जो – Heinrich

उत्तर

11

समस्या एक Nuget पैकेज Microsoft.Net.Compilers स्थापित करने तय किया जा सकता है। Project builds fine with Visual Studio but fails from the command line

That feature is a syntactic sugar for C#6, try to install the latest version of the framework 4.6.2 https://www.microsoft.com/en-us/download/details.aspx?id=53345

Then go to your Project properties and change on the Application option on Target framework to point to the latest. You don't need to change your code to replace the string interpolation with string.Format method to fix it. If you are still getting this error, is because, the compiler that is running your build is not the latest version of C#, try to add the Microsoft.Net.Compilers, from Nuget and compile again, that should resolve the issue. If you want to avoid to install this package, try to open your .csproj and take a look on the ToolsVersion.that should be pointing to the version 12, then change it to 14, but make sure you have installed the latest version of the MSBuild from https://www.microsoft.com/en-us/download/details.aspx?id=48159 or go to C:\Program Files (x86)\MSBuild\14.0\Bin, there you should have this folder with the csc.exe compiler. If even then that doesn't resolve the issue, then try to follow this steps https://msdn.microsoft.com/en-us/library/bb383985.aspx .

मेरे अनुभव में मैं 3 अलग अलग तरीकों से इस समस्या का समाधान:

1- सिर्फ Nuget

से पैकेज हो रही

2- माइक्रोसॉफ्ट का निर्माण स्थापित करने के नीचे मेरी प्रकाश डाला जवाब का लिंक है टूल्स सर्वर

3- स्लेजहैमर और अंतिम विकल्प लेकिन मेरे लिए सबसे अच्छा है क्योंकि आपको nuget पर निर्भरता से निपटने की आवश्यकता नहीं है, tfs सर्वर पर दृश्य स्टूडियो संस्करण स्थापित कर रहा है जहां आप ru एन प्रक्रिया।

आशा इस मदद करता है

+0

इस Nuget पैकेज के लिए निर्भरता स्थापित करने से मेरी समस्या ठीक हो गई। यदि मेरे पास 100 परियोजनाएं हैं तो निर्भरता स्थापित करने से बचने का कोई तरीका है? – Heinrich

+0

यहां मेरे उत्तर पर एक नज़र डालें http://stackoverflow.com/a/43072823/819153 – Zinov

0

मैं अनुमान लगा रहा हूं कि आपके पास स्ट्रिंग इंटरपोलेशंस के साथ कोड है और proper build tools नहीं है।

+0

असल में मेरे पास उस उपकरण का उच्च संस्करण है जो सर्वर – Heinrich

+0

पर स्थापित है, यह उस कोड को देखने में मदद करेगा जहां त्रुटि हो रही है। –

9

%ProgramFiles%\MSBuild\14.0\bin में MS Build tools 2015 स्थापित करने के बाद आप नए मूल्य (14.0) के साथ override the MSBuild version for build server की जरूरत है।

आप MSDN लेख पढ़ना चाहिए (या this answer), लेकिन टी एल; डॉ अपने विकल्प हैं: /ToolsVersion स्विच (या /tv, छोटे के लिए) का उपयोग कर जब आप का निर्माण द्वारा

  • अवहेलना संस्करण परियोजना या कमांड लाइन से समाधान:पर ToolsVersion पैरामीटर की स्थापना करके

    msbuild.exe someproj.proj /tv:14.0 /p:Configuration=Debug 
    
  • अवहेलना संस्करणकार्य: एक समाधान के भीतर एक परियोजना पर $(Project.ToolsVersion) संपत्ति की स्थापना द्वारा

    <MSBuild Projects="myProject.proj" 
        ToolsVersion="14.0" 
        Targets="go" /> 
    
  • अवहेलना संस्करण। यह आपको एक ToolsetVersion कि अन्य परियोजनाओं से भिन्न के साथ एक समाधान में एक परियोजना का निर्माण कर सकते हैं:

    <Project ToolsVersion="14.0" ... </Project> 
    

The order of precedence, from highest to lowest, used to determine the ToolsVersion is:

  1. The ToolsVersion attribute on the MSBuild task used to build the project, if any.
  2. The /toolsversion (or /tv) switch that's used in the msbuild.exe command, if any.
  3. If the environment variable MSBUILDTREATALLTOOLSVERSIONSASCURRENT is set, then use the current ToolsVersion .
  4. If the environment variable MSBUILDTREATHIGHERTOOLSVERSIONASCURRENT is set and the ToolsVersion defined in the project file is greater than the current ToolsVersion , use the current ToolsVersion .
  5. If the environment variable MSBUILDLEGACYDEFAULTTOOLSVERSION is set, or if ToolsVersion is not set, then the following steps are used:
    • The ToolsVersion attribute of the Project element of the project file. If this attribute doesn’t exist, it is assumed to be the current version.
    • The default tools version in the MSBuild.exe.config file.
    • The default tools version in the registry. For more information, see Standard and Custom Toolset Configurations .
  6. If the environment variable MSBUILDLEGACYDEFAULTTOOLSVERSION is not set, then the following steps are used:
    • If the environment variable MSBUILDDEFAULTTOOLSVERSION is set to a ToolsVersion that exists, use it.
    • If DefaultOverrideToolsVersion is set in MSBuild.exe.config , use it.
    • If DefaultOverrideToolsVersion is set in the registry, use it.
    • Otherwise, use the current ToolsVersion .
+0

मैंने इन सभी परिवर्तनों का प्रयास किया, यहां तक ​​कि मैं डिफ़ॉल्ट संस्करण को 14.0 पर बदलने के लिए रजिस्टर पर मान भी बदलता हूं, मैंने MSBuild.exe.config को भी बदल दिया लेकिन सब कुछ असफल रहा। मेरे प्रोजेक्ट में सही टूल्स वर्जन – Heinrich

+1

@ हेनरिक है, आपको यह सुनिश्चित करने की भी आवश्यकता है कि आप "सी: \ प्रोग्राम फ़ाइलें (x86) \ Microsoft Visual Studio \ 2017 \ BuildTools \ MSBuild \ 15.0 \ Bin \" से msbuild.exe चला रहे हैं। सी से नहीं: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \) – Shrike

+1

मेरे लिए पथ '"% प्रोग्रामफाइल (x86)% \ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ 15.0 \ Bin \ msbuild.exe था " – knocte

2

इसकी भी संभावना है तुम गलत MSBuild.exe साथ निर्माण कर रहे हैं है, विजुअल स्टूडियो में संकलित करें (जहां यह काम करता है) और आउटपुट में लॉग की जांच करें। वहाँ होना चाहिए की तरह कुछ:

1>Target "GetReferenceAssemblyPaths" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets" 

आपको लगता है कि बिन निर्देशिका में MSBuild.exe उपयोग कर रहे हैं, मेरे मामले में सुनिश्चित करें;

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSbuild.exe 
संबंधित मुद्दे