2011-01-20 2 views
3

У меня очень простая настройка, это целое решение, которое создается с использованием .NET 3.5. Хорошо работает на моей машине и сервере сборки. С тех пор я добавил скрипт в мой файл сборки, который создаст файл XML, в котором перечислены все обновления для нашего патчера. Это нормально работает на моей машине, , но совсем не на сервере сборки.Nant Script с использованием .Net 2? Зачем?

Я приложил вывод ниже, как ни странно, он, похоже, компилирует сценарий в .NET 2.0? Это никогда не будет работать, потому что LINQ присутствует в скрипте.

У кого-нибудь есть идеи? Заранее спасибо ...

NAnt 0.90 (Build 0.90.3780.0; release; 08/05/2010) 
Copyright (C) 2001-2010 Gerry Shaw 
http://nant.sourceforge.net 

Buildfile: file:///E:/Build/Importers/nant.importers.build 
Target framework: Microsoft .NET Framework 3.5 
Base Directory: E:\Build\Importers. 

generateUpdateXml: 

    [script] Adding assembly NAnt.Core 
    [script] Adding assembly System.Xml 
    [script] Adding assembly System.Data.Linq 
    [script] Adding assembly System.Core 
    [echo] Compilation failed: 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(32,22) : error CS1026:) expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(32,27) : error CS1002: ; expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(32,27) : error CS1525: Invalid expression term 'in' 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(32,30) : error CS1002: ; expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(32,96) : error CS1002: ; expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(33,16) : error CS1002: ; expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(34,9) : error CS1031: Type expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(35,28) : error CS1002: ; expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(35,28) : error CS1525: Invalid expression term ',' 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(35,29) : error CS1002: ; expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(36,58) : error CS1002: ; expected 
    [echo] c:\Documents and Settings\dean.thomas\Local Settings\Temp\1\fjgfnsgk.0.cs(37,17) : error CS1525: Invalid expression term ')' 
    [echo] //------------------------------------------------------------------------------ 
    [echo] // <auto-generated> 
    [echo] //  This code was generated by a tool. 
    [echo] //  Runtime Version:2.0.50727.3615 
    [echo] // 
    [echo] //  Changes to this file may cause incorrect behavior and will be lost if 
    [echo] //  the code is regenerated. 
    [echo] // </auto-generated> 
    [echo] //------------------------------------------------------------------------------ 
    [echo] 
    [echo] using NAnt.Core; 
    [echo] using NAnt.Core.Attributes; 
    [echo] using System; 
    [echo] using System.Collections; 
    [echo] using System.IO; 
    [echo] using System.Linq; 
    [echo] using System.Reflection; 
    [echo] using System.Text; 
    [echo] using System.Xml; 
    [echo] 
    [echo] 
    [echo] 
    [echo] [FunctionSet("script", "script")] 
    [echo] public class nant4430d2e24afc4e1eb4d68138bbb0e3a0 : NAnt.Core.FunctionSetBase { 
    [echo]  
    [echo] 
    [echo]   public static void ScriptMain(Project project) 
    [echo]   { 
    [echo]    string outputFolder = string.Format(@"{0}\{1}\", project.Properties["publish.dir.NetworkPath"], project.Properties["Project"]); 
    [echo]  project.Log(Level.Info, outputFolder); 
    [echo] 
    [echo] var allItems = (from file in Directory.GetFiles(outputFolder, "*", SearchOption.AllDirectories) 
    [echo]   select new 
    [echo]   { 
    [echo]    Filename = file, 
    [echo]  LastModified = System.IO.File.GetLastWriteTime(file) 
    [echo]    }); 
    [echo]   /*       
    [echo]   XmlDocument xDoc = new XmlDocument(); 
    [echo]   xDoc.AppendChild(xDoc.CreateXmlDeclaration("1.0", "UTF-8", null)); 
    [echo]    
    [echo]   XmlElement feedElement = xDoc.CreateElement("Feed"); 
    [echo]   XmlElement tasksElement = xDoc.CreateElement("Tasks"); 
    [echo] 
    [echo]   foreach (var item in allItems) 
    [echo]   { 
    [echo]    XmlElement fileUpdateElement = xDoc.CreateElement("FileUpdateTask"); 
    [echo]    string parentFolder = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(item.Filename)); 
    [echo]    
    [echo]    fileUpdateElement.SetAttribute("updateTo", item.Filename); 
    [echo]    
    [echo]    if (parentFolder == "Importers") 
    [echo]    { 
    [echo]    //Do this 
    [echo]    fileUpdateElement.SetAttribute("apply", "hot-swap"); 
    [echo]    fileUpdateElement.SetAttribute("localPath", string.Format(@"Importers\{0}", System.IO.Path.GetFileName(item.Filename))); 
    [echo]    } 
    [echo]    else 
    [echo]    { 
    [echo]    //Do that 
    [echo]    fileUpdateElement.SetAttribute("apply", "app-restart"); 
    [echo]    fileUpdateElement.SetAttribute("localPath", System.IO.Path.GetFileName(item.Filename)); 
    [echo]    } 
    [echo]       
    [echo]    //Condition, which we can just use the timestamp of the upload 
    [echo]    XmlElement conditions = xDoc.CreateElement("Conditions"); 
    [echo]    XmlElement fileDateCondition = xDoc.CreateElement("FileDateCondition"); 
    [echo]    fileDateCondition.SetAttribute("type", "and"); 
    [echo]    fileDateCondition.SetAttribute("what", "newer"); 
    [echo]    fileDateCondition.SetAttribute("timestamp", item.LastModified.ToString("dd/MM/yyyy HH:MM:ss")); 
    [echo]    conditions.AppendChild(fileDateCondition); 
    [echo]    fileUpdateElement.AppendChild(conditions); 
    [echo]    tasksElement.AppendChild(fileUpdateElement); 
    [echo]   } 
    [echo] 
    [echo]   feedElement.AppendChild(tasksElement); 
    [echo]   xDoc.AppendChild(feedElement); 
    [echo]   xDoc.Save("c:\\testing.xml");  */       
    [echo]   } 
    [echo]  
    [echo]  public nant4430d2e24afc4e1eb4d68138bbb0e3a0(NAnt.Core.Project project, NAnt.Core.PropertyDictionary propDict) : 
    [echo]    base(project, propDict) { 
    [echo]  } 
    [echo] } 
    [echo] 

BUILD SUCCEEDED 

Total time: 0.7 seconds. 
+0

Вы уверены, что это имеет значение? 3.5 работает только над 2.0. – Jess

+0

Действительно. Но он не будет компилироваться из-за присутствия LINQ. Таким образом, мой скрипт после сборки не запускался. Я переписал его, чтобы не использовать linq, и он запускает лечение ... –

ответ

3

У меня тоже была эта проблема, и мне пришлось прекратить использовать функции 3.5 в моем сценарии NAnt.

Похоже, что NAnt компилирует код из вашего блока с помощью компилятора v2.0, поскольку сам NAnt был построен с компилятором v2.0.

Там хак к исходному коду NAnt предложил здесь:

http://www.mail-archive.com/[email protected]/msg11867.html

2

Он говорит на вершине, что целевая база 3,5 и сборка удалось, так что я думаю, что ты в порядке. Похоже, что 2.0 - это просто версия фреймворка, которая сгенерировала скрипт NAnt.

+0

Действительно, похоже, что правильное построение решения. Но сценарий внутри файла сборки не так много. Очень странно, мне просто пришлось перезаписать его без linq. –

Смежные вопросы