2017-03-21 29 views
14

Çerçevenin .NET Framework 4.6.1 hedeflediği bir proje var, tfs üzerinde sürekli tümleştirme işleminin bir parçası olarak bir Build Solution görevi oluşturduğumuzdan emin olmak için kod doğru şekilde derler.
Artık TFS sunucusu, .Net Famework 4.6.2'un en son sürümüne sahiptir. kasada Bu çerçevede

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

Ama Yayın anahtarının değerdir inşa bu hata ile gelir çalıştığında: Birlikte dize interpolasyon değiştirmek istemiyorum

Error CS1056: Unexpected character '$' 

Bu sorunu çözmek için string.Format, lütfen çözmek için başka bir geçici çözüm sağlayın.

TFS sunucusuna başka bir şey yüklemem gerekir mi?

+0

Sunucuda hangi MSBuild sürümü çalışıyor? –

+0

'MSBuild 'aracını güncellemeniz gerekir, .NET' çerçevesi değil – VMAtm

+0

@ VMAtm bunu nasıl yapabilirim? Ben sadece https://www.microsoft.com/en-us/download/details.aspx?id=48159 indirdi ve bu başarısız olan bir – Heinrich

cevap

11

Sorun Nuget paketini Microsoft.Net.Compilers yükleyerek düzeltilebilir. 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 .

Benim durumumda ben 3 farklı şekilde bu sorunu çözdü:

1- sadece

2- Nuget

paketi alma Microsoft kurmak yüklemeden Aşağıda benim vurgulanan cevabın link Tfs sunucusundaki araçlar 2015

3- Balyoz ve son seçenekler ancak benim için en iyisi, çünkü nuget üzerindeki bağımlılıkla başa çıkmak zorunda değilsiniz, görsel stüdyo sürümünü tFS sunucusunda kuruyorsunuz. süreç.

Umut bu yanlış MSBuild.exe ile inşa ediyoruz olma ihtimali de var

+0

Bu Nuget paketi için bağımlılığın yüklenmesi sorunumu düzeltti. 100 projem varsa bağımlılığı kurmaktan kaçınmanın bir yolu var mı? – Heinrich

+0

Cevabıma bir bakın http://stackoverflow.com/a/43072823/819153 – Zinov

0

Sadece dize enterpolasyonlu kodunuz olduğunu tahmin ediyorum ve proper build tools'a sahip değilsiniz.

+0

Aslında, bu aracın – Heinrich

+0

sunucusunda yüklü olan daha yüksek bir sürümüne sahibim. Hatanın gerçekleştiği yerde kodun görülmesine yardımcı olurdu. –

9

MS Build tools 2015'u %ProgramFiles%\MSBuild\14.0\bin'a yükledikten sonra override the MSBuild version for build server numaralı yeni değere sahip olmanız gerekir (14.0). ;

MSDN makaleyi okumalısınız (veya this answer), ancak TL DR seçenekleriniz şunlardır: Eğer oluştururken (kısaca veya /tv) /ToolsVersion anahtarını kullanarak

  • geçersiz kıl versiyonu komut satırından projesi veya çözüm:üzerine ToolsVersion parametresini ayarlayarak

    msbuild.exe someproj.proj /tv:14.0 /p:Configuration=Debug 
    
  • geçersiz kıl versiyonugörev: Bir çözüm içinde bir proje üzerinde $(Project.ToolsVersion) özelliğini ayarlayarak

    <MSBuild Projects="myProject.proj" 
        ToolsVersion="14.0" 
        Targets="go" /> 
    
  • geçersiz kıl sürümü. Bu, diğer projelerin farklılık gösteren bir ToolsetVersion ile bir çözümde bir proje oluşturmanıza olanak sağlar:

    <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

Tüm bu değişiklikleri denedim, kayıt defterindeki değerleri varsayılan sürümü 14.0 olarak değiştirdim, ayrıca MSBuild.exe.config değiştirdim ama her şey başarısız oldu. Projemin doğru ToolsVersion – Heinrich

+1

@Heinrich'e sahip olmanız gerekir, ayrıca "C: \ Program Files (x86) \ Microsoft Visual Studio \ 2017 \ BuildTools \ MSBuild \ 15.0 \ Bin \" adresinden msbuild.exe çalıştırdığınızdan emin olmanız gerekir (C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \) – Shrike

+1

benim için değil, "% ProgramFiles (x86)% \ Microsoft Visual Studio \ 2017 \ Community \ MSBuild \ 15.0 \ Bin \ msbuild.exe "' – knocte

2

yardımcı olur; Visual Studio'da (çalıştığı yerde) derleyin ve çıktıları günlük olarak kontrol edin.

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

Aşağıdaki gibi bir şey olmalıdır: Benim durumumda, bu Bin dizininde MSBuild.exe kullandığınızdan emin olun;

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSbuild.exe