I'm attempting to compile my new C# 7 code on a Linux build server using Mono 5. Unfortunately, the project fails when I use the new ValueTuple syntax:
MyClass.cs(100,38): error CS1003: Syntax error, '(' expected [/path/to/My.csproj]
I have the following package reference in my project file:
<PackageReference Include="System.ValueTuple" Version="4.3.0" />
and I'm using the following commands in my quick build script:
# msbuild My.sln /t:restore
# msbuild My.sln /p:Configuration=Release /p:Platform="Any CPU"
and the MSBuild log indicates a language version of 7 and shows a reference to System.ValueTuple.dll:
CoreCompile:
/usr/lib/mono/4.5/csc.exe /noconfig /unsafe- /checked- /nowarn:1701,1702,1705,1701,1702 /langversion:7 /nostdlib+ /errorreport:prompt /warn:4 /doc:bin/Release/net461/My.xml /define:TRACE;RELEASE;NET461 /highentropyva+ ... /reference:/root/.nuget/packages/system.valuetuple/4.3.0/lib/netstandard1.0/System.ValueTuple.dll ... /debug- /debug:portable /filealign:512 /nologo /optimize+ /out:obj/Release/net461/My.dll /subsystemversion:6.00 /target:library /warnaserror- /utf8output /deterministic+ My.cs "/tmp/.NETFramework,Version=v4.6.1.AssemblyAttributes.cs" obj/Release/net461/My.AssemblyInfo.cs
Has anyone successfully compiled C# using the new ValueTuple syntax on Linux using Mono 5? Did it just work, or did you need to adjust the environment to make it work?
My build server is running Ubuntu 16.04 and has mono-devel 5.0.1.1-0xamarin5+ubuntu1604b1 installed.
I uninstalled the stable mono-devel 5.0.1.1-0xamarin5+ubuntu1604b1 and replaced it with the beta mono-devel 5.2.0.196-0xamarin7+ubuntu1604b1. The project now compiles without error.
I will assume that a bug in mono has been fixed that resolves this issue.
Related
Step :1
Code:
dotnet build E:\abc.csproj /p:Platform=ANYCPU /p:Configuration=Release
.
Error:
C:\Program Files\dotnet\sdk\5.0.202\Microsoft.Common.CurrentVersion.targets(3624,5): error MSB3474: The tas
k "SGen" is not supported on the .NET Core version of MSBuild. Use the Microsoft XML Serializer Generator p
ackage instead. See https://go.microsoft.com/fwlink/?linkid=858594 for more information. [E:\abc.csproj]
Step:2 I had applied the below solution but didn't work.
Command:dotnet add E:\abc.csproj package Microsoft.XmlSerializer.Generator -v 1.0.0
I had read a document and implement a solution but the solution has some issues. sp command: 'dotnet add E:\abc.csproj package Microsoft.XmlSerializer.Generator -v 1.0.0' Error: Determining projects to restore... Writing C:\Users\AppData\Local\Temp\tmpF1E.tmp info : Adding PackageReference for package 'Microsoft.XmlSerializer.Generator' into project 'E:\abc.csproj'. error: Error while adding package 'Microsoft.XmlSerializer.Generator' to project 'E:\abc.csproj'. The project does not support adding package references through the add package command.
https://go.microsoft.com/fwlink/?linkid=858594
Remove this line from the csproj file:
<GenerateSerializationAssemblies>On</GenerateSerializationAssemblies>
I have Service Fabric based system created and working on production environment (and development). Everything is ok. Now I was trying to setup CI on Visual Studio Team Services with provided templates for ASF projects.
Unfortunately my system has Actors (.NET 4.5.2) and WebAPI based on ASP.NET Core 1.1. I have references to Actor interfaces project (also .NET 4.5.2) forom .NET Core.
When I'm trying to build project with default template I'm recieving error because dotnet restore was not run. Ok, so I've added step to run dotnet restore but then I'm getting error complaining that it cannot find reference to Actor.Interfaces.
dotnet restore also fails on my dev machine but solution build with VS goes ok.
How can I fix this issue?
[UPDATE]
Thanks Mardoxx, I've made some progress... now I'm getting below error for *.sln buld. My solution is VS2015 (set in build task), I've set env to Hosted VS2017.
IntegrationApi\IntegrationApi.xproj(7,11): Error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\DotNet\Microsoft.DotNet.Props" was not found. Also, tried to find "DotNet\Microsoft.DotNet.Props" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Project "d:\a\1\s\Labelcall.sln" (1) is building "d:\a\1\s\IntegrationApi\IntegrationApi.xproj" (18) on node 1 (default targets).
d:\a\1\s\IntegrationApi\IntegrationApi.xproj(7,11): error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\DotNet\Microsoft.DotNet.Props" was not found. Also, tried to find "DotNet\Microsoft.DotNet.Props" in the fallback search path(s) for $(VSToolsPath) - "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\amd64\msbuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.
Done Building Project "d:\a\1\s\IntegrationApi\IntegrationApi.xproj" (default targets) -- FAILED.
[UPDATE2]
After taking steps presented by starain-MSFT I'm getting errors during 'dotnet restore':
log : Restoring packages for d:\a\1\s\AdminPanel\project.json...
error: Unable to resolve 'AccountActor.Interfaces' for
'.NETFramework,Version=v4.5.2'.
error: Unable to resolve 'CommonContracts' for
'.NETFramework,Version=v4.5.2'.
error: Unable to resolve 'CommonInfrastructure' for
'.NETFramework,Version=v4.5.2'.
[UPDATE3]
Another update after #starain input.
Now I'm getting error that references (to .NET 4.5.2 projcects from Core projects) could not be found.
Project "d:\a\1\s\LabelcallApplication\LabelcallApplication.sfproj" (2) is building "d:\a\1\s\MobileApi\MobileApi.xproj" (19) on node 1 (default targets).
PrepareForBuild:
Creating directory ".\bin\".
Creating directory ".\obj\Release\".
PreComputeCompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe --noEmitOnError --listEmittedFiles
CompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\tsc.exe --noEmitOnError --listEmittedFiles
CoreCompile:
C:\Program Files\dotnet\dotnet.exe build "d:\a\1\s\MobileApi" --configuration Release --no-dependencies
Project MobileApi (.NETFramework,Version=v4.5.2) will be compiled because expected outputs are missing
Compiling MobileApi for .NETFramework,Version=v4.5.2
C:\Program Files\dotnet\dotnet.exe compile-csc #d:\a\1\s\MobileApi\obj\Release\net452\dotnet-compile.rsp returned Exit Code 1
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.DependencyCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.DependencyCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.PerfCounterCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.PerfCounterCollector 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
MobileApi\project.json(6,44): Warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0
d:\a\1\s\MobileApi\project.json(6,44): warning NU1012: Dependency conflict. Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel 2.2.0 expected Microsoft.ApplicationInsights 2.2.0 but received 2.3.0 [d:\a\1\s\MobileApi\MobileApi.xproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\ContactActor.Interfaces\bin\Release\ContactActor.Interfaces.dll' could not be found
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\ContactActor.Interfaces\bin\Release\ContactActor.Interfaces.dll' could not be found [d:\a\1\s\MobileApi\MobileApi.xproj]
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): Error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\DeviceActor.Interfaces\bin\Release\DeviceActor.Interfaces.dll' could not be found
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Common.Targets(262,5): error : d:\a\1\s\MobileApi\error CS0006: Metadata file 'd:\a\1\s\DeviceActor.Interfaces\bin\Release\DeviceActor.Interfaces.dll' could not be found [d:\a\1\s\MobileApi\MobileApi.xproj]
Compilation failed.
3 Warning(s)
2 Error(s)
Time elapsed 00:00:01.7675632
Refer to these steps below:
Create a new build definition with Azure Service Fabric Application template
Change Visual Studio Version to Visual Studio 2015 for Visual Studio Build steps.
Select NuGet Installer step/task, change NuGet version to 3.5.0 in Advanced section.
Select Options tab and change Default agent queue to Hosted
Queue build with Hosted agent. (Not Hosted VS 2017)
All build steps:
NuGet Installer (NuGet restore ***.sln)
.Net Core (dotnet restore)
Visual Studio Build (Build solution ***.sln)
Visual Studio Build (Build solution ***.sfproj)
Copy Files
Delete files
Update Service Fabric App Versions
Copy Files
Publish Build Artifacts
I have a requirement to work with Jenkins for Continues integration, in my code I have written code like
throw new ArgumentNullException($"The {nameof(Id)} cannot be null");
If I build the application it is building successfully but if I build this same application using MsBuild(or) Jenkins,
I am getting error like
Web\WebSharedHelper.cs "C:\WINDOWS\TEMP\.NETFramework,Version=v4.5.2.AssemblyAttributes.cs"
Security\ApiUserToken.cs(46,32): error CS1056: Unexpected character '$' [C:\Program Files (x86)\Jenkins\workspace\OssiaCICD\common\trunk\Cota.Common.Core\Cota.Common.Core.csproj]
Security\ApiUserToken.cs(58,32): error CS1056: Unexpected character '$' [C:\Program Files (x86)\Jenkins\workspace\OssiaCICD\common\trunk\Cota.Common.Core\Cota.Common.Core.csproj]
Security\ApiUserToken.cs(62,26): error CS1056: Unexpected character '$' [C:\Program Files (x86)\Jenkins\workspace\OssiaCICD\common\trunk\Cota.Common.Core\Cota.Common.Core.csproj]
Done Building Project "C:\Program Files (x86)\Jenkins\workspace\OssiaCICD\common\trunk\Cota.Common.Core\Cota.Common.Core.csproj" (default targets) -- FAILED.
I am using v4.0.30319 FrameWork for MSBuild.
I fixed the problem by using C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe instead of C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe on jenkins.
The $ string interpolation symbol is only available in C# 6+. Make sure that you are compiling with C#6. C#6 is supported in MSBuild 14.0+.
If your Visual Studio version is older than 2015 then by default the IDE does not provide C#6 which you need to compile it.
Use Visual Studio 2015 or newer. It should resolve problem.
This problem can be resolved in a couple of ways. Please check my answer here
for the first option:
1st https://stackoverflow.com/a/42931980/819153
2nd option - Try to install the visual studio on the tfs where you run the continuous integration, that will save you a lot of headaches
As suggested by a gentleman here, I used C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe instead of C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe over the build agent.
And it helped me.
I have MSBuild Version 14.0.25420.1 in the build agent.
In my case, worked below..
Removed langversion nodes and added netstandard reference to csproj for msbuild to work with Jenkins or msbuild command.
commented below lines in .csproj file.
<!-- <LangVersion>8.0</LangVersion>-->
And added <Reference Include="netstandard" /> for more-info
I am using the new MSBuild 15 distributed with VS2017 RC to compile and pack a multi targeting project.
Restoring: msbuild /t:restore mysolution.sln works correctly.
Building: msbuild /p:Configuration=Release mylibrary.csproj works correctly and generates:
+ bin/Release
+ netstandard1.4
- mylibrary.dll
+ net452
- mylibrary.dll
But when I am packing: msbuild /t:pack /p:Configuration=Release /p:IncludeSymbols=true mylibrary.csproj the structure does not match well with the previous build, looking like:
+ bin/Release
+ netstandard1.4
- mylibrary.pdb
+ net452
- mylibrary.pdb
- mylibrary.dll
Warnings from the /t:pack command show me this was gonna happen, but not sure how to solve it:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Issue found with package 'MyLibrary'. [D:\XXX\YYY\src\MyLibrary\MyLibrary.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Issue: Assembly not inside a framework folder. D:\XXX\YYY\src\MyLibrary\MyLibrary.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Description: The assembly 'lib\MyLibrary.dll' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder.
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(73,5): warning : Solution: Move it into a framework-specific folder. If this assembly is targeted for multiple frameworks, ignore this warning.
Notes:
I am not using a *.nuspec file. Just the new way *.csproj files work (https://docs.nuget.org/ndocs/schema/msbuild-targets#pack-target)
This is how some of the relevant content of the file look like:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>library</OutputType>
<TargetFrameworks>netstandard1.4;net452</TargetFrameworks>
<AssemblyName>MyLibrary</AssemblyName>
<Authors>XXX</Authors>
<Description>YYY</Description>
<PackageId>MyLibrary</PackageId>
<PackageVersion>1.2.3</PackageVersion>
</PropertyGroup>
</Project>
Thanks for your comments. I found my way on based on them.
This is what I did: I downloaded the dotnet cli tool again and test it from scratch. I realized that the version of the cli tool were the same so I started comparing the files inside.
Wrong dotnet cli version
The version that was not working contained the following files:
+ dotnet
+ sdk
+ 1.0.0-preview2-1-003177
+ 1.0.0-preview2-003131
+ 1.0.0-preview2-003133
+ 1.0.0-preview4-004233
Using dotnet build /t:pack /p:Configuration=Release /p:IncludeSymbols=true mylibrary.csproj showed the following error:
Couldn't find 'project.json' in '/t:pack'
Good dotnet cli version
The second version I downloaded contained only these:
+ dotnet
+ sdk
+ 1.0.0-preview4-004233
And executing the command before, it works correctly:
Microsoft (R) Build Engine version 15.1.458.808
Copyright (C) Microsoft Corporation. All rights reserved.
...
I have an .WPF application.Using XBAP project the project as web application. The solution file having 15 projects. Among 15 projects, one is root project names 'cp'. This has other project dll. i am able to build the code. My goal is that to Publish in one Location (Ex: c:\publish)in the file format of '.deploy' of all the project(Ex: sampleproject.dll.deploy). How command should i use.? I have tried following command one by one. Nothing give proper .deploy package.
R&D
msbuild cp.sln /p:DeployOnBuild=true /p:PublishProfile=Test
msbuild cp.sln /p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="C:\Publish";AutoParameterizationWebConfigConnectionStrings=false
msbuild cp.sln /p:DeployOnBuild=true;DeployTarget=Package
msbuild cp.sln /p:DeployOnBuild=true /p:PublishProfile=FileSystemDebug
msbuild cp.sln /p:DeployOnBuild=true /p:PublishProfile=myprofile
msbuild cp.csproj /p:DeployOnBuild=true /p:PublishProfile=myprofile.
msbuild cp.csproj "/p:Platform=AnyCPU;Configuration=Release;PublishDestination=C:\Publish" /t:PublishToFileSystem
If you set your publish profile and publish directory is "c:\publish" you should use the following windows commands. I suppose that You are using MSbuild 14.0.
For Windows Machine
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /p:DeployOnBuild=true /p:PublishProfile="C:\PublishProfiles\testprofile.pubxml" "C:\Myapp\Myproject.sln"
For Azure
C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" /p:DeployOnBuild=true /p:AllowUntrustedCertificate=true /p:PublishProfile="C:\PublishProfiles\testprofile.pubxml" /p:Password=xxxxx "C:\Myapp\Myproject.sln"