Home Dashboard Directory Help
Search

using System.Linq, without reference to System.Core => compiles in VS, but not with msbuild.exe v3.5 by jaapq42


Status: 

Closed
 as By Design Help for as By Design


2
0
Sign in
to vote
Type: Bug
ID: 665406
Opened: 4/28/2011 2:52:02 AM
Access Restriction: Public
1
Workaround(s)
view
1
User(s) can reproduce this bug

Description

* Convert .NET 2.0 classlibrary to .NET 3.5
* Create new class file (verify that System.Linq is added to the usings)
* Compile with VS 2010 => works
* Compile with msbuild.exe => fails on the System.Linq namespace not being referenced
Details
Sign in to post a comment.
Posted by Microsoft on 5/4/2011 at 5:03 PM
Hi Jaapq42, I hadn't realized that you were asking MSBuild 3.5 to build the converted project. MSBuild 3.5 will try, but fail in some cases (like here) - simply because it was shipped in 2008 before VS2010 existed. You must use 4.0 (or any future versions) to build VS2010 projects, in general.
It's possible in this case you can add a reference explicitly to System.Core.

Dan
Posted by jaapq42 on 5/4/2011 at 12:44 AM
I'm building with msbuild 3.5:

Microsoft (R) Build Engine Version 3.5.30729.5420
[Microsoft .NET Framework, Version 2.0.50727.5420]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

MSBUILD : error MSB1001: Unknown switch.
Switch: /pp:out.txt

For switch syntax, type "MSBuild /help"

I haven't tried msbuild 4.0, because we don't have .NET 4.0 installed yet on our continuous integration server.
Posted by Microsoft on 5/3/2011 at 4:52 PM
jjapq42,
I unzipped all your projects and built each in turn with msbuild.exe /t:rebuild. I used msbuild.exe 4.0 with SP1. It built successfully in all cases.
Can you please provide
(1) msbuild.exe /pp:out.txt <yourprojectthatwon'tbuildhere> then provide out.txt
(2) diagnostic verbosity logs (ie /flp:v=diag then supply msbuild.log) for this too
dan
Posted by Microsoft on 5/2/2011 at 10:58 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by jaapq42 on 5/2/2011 at 1:52 AM
I added three zip files, but they don't show up yet...
Posted by jaapq42 on 5/2/2011 at 1:51 AM
step1:
Created a empty console app in vs2010, .net 2.0.
Converted it to .net 3.5

step2:
Added class from the new Class dialog. (notice line 3: using System.Linq)
Compiles ok in vs2010

step 3:
I used build.bat to build from commandline with msbuild.exe:

Class1.cs(3,14): error CS0234: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)
Posted by Microsoft on 4/28/2011 at 8:22 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project to demonstrate this issue so that we can conduct further research?

Please submit this information to us within 4 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 4/28/2011 at 3:13 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by DanTup on 11/6/2012 at 12:57 AM
I was able to work around this by manually inserting a reference to System.Core in csproj (you can't do it in VS, it tells you it's not required):

    <Reference Include="System.Core">
     <Name>System.Core</Name>
    </Reference>
File Name Submitted By Submitted On File Size  
ConsoleApplication1-step3.zip 5/2/2011 3 KB
ConsoleApplication1-step2.zip 5/2/2011 3 KB
ConsoleApplication1-step1.zip 5/2/2011 3 KB