I'm trying F# and have a tiny project where I could run dotnet test, but I wanted to do it without installing any non-free software from Microsoft.
Alternatives to using dotnet all seem to use pretty complex commands like:
$ mono packages/xunit.runner.console.2.0.0/tools/xunit.console.exe build/test/CommandLine.Tests.dll
Being a complete newcomer, I have zero hint how those might need tweaking to work in my case.
My HelloWorld.fsproj contains:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<Compile Include="HelloWorld.fs" />
<Compile Include="HelloWorldTests.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="FsUnit.xUnit" Version="4.0.2" />
</ItemGroup>
</Project>
Both Mono and .NET core have an MIT license. There's no reason you should not use .NET core nowadays, specially with .NET core 5 which is aiming at unifying the capabilities of .NET core and Mono.
On another note, there's an unnecessary line in your project code if you're not using Visual Studio (commercial license).
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
Related
I get this error building my specflow test project
I cannot figure out why I get these compile bugs..
I am quite sure it has to do with use .NET 5,
don't have a lib folder, where the libraries/nugets are stored...
my project looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="FluentAssertions" Version="6.7.0" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<OutputPath>..\Bin\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<OutputPath>..\Bin\Release</OutputPath>
</PropertyGroup>
<ItemGroup>
<Folder Include="Drivers\" />
<Folder Include="Hooks\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MagVenture.Utilities.UI\MagVenture.Utilities.UI.csproj" />
</ItemGroup>
I cannot figure it out... - there is a twirl somewhere that I didn't see..
Disable the NU5100 warning, when treating warnings as errors.
it is due to the .NET framework versions policies about location in lib folder.
What follows is a VS2019 project file for a C++/CLI application. The goal is to upgrade it from being a .Net Framework to a .Net Standard 2.0.
It was compiling and linking find with .Net Core 5.0 until I started to deal with the whole log4net reference. In other words, the .Net Core 5.0 was NOT trying to pass an log4net interface into this library and all was good. Once one was passed in, there where errors. The old log4net reference was pulled out of this project and replaced with one to the .Net Standard 2.0. Now there is this error:
warning MSB3268: The primary reference "log4net" could not be resolved because it has an indirect dependency on the framework assembly "netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.0". To resolve this problem, either remove the reference "log4net" or retarget your application to a framework version which contains "netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
AFile.h(3): error C2871: 'log4net': a namespace with this name does not exist
I simply am not seeing any reference in the project file to either .Net Framework or .Net Standard. How do I fix this issue?
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9FAC29B5-62B2-4323-9469-921B467C8433}</ProjectGuid>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<RootNamespace>theCppCliLibraryName</RootNamespace>
<Keyword>ManagedCProj</Keyword>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>true</CLRSupport>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>14.0.25431.1</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>true</LinkIncremental>
<LinkKeyFile>theCppCliLibraryName.snk</LinkKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
<LinkIncremental>false</LinkIncremental>
<LinkKeyFile>theCppCliLibraryName.snk</LinkKeyFile>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>LicenseLib2015MDd.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention />
<TargetMachine>MachineX86</TargetMachine>
<Profile>true</Profile>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>LicenseLib2015MD.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>../../lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention />
<TargetMachine>MachineX86</TargetMachine>
<SubSystem>Windows</SubSystem>
<ShowProgress>LinkVerbose</ShowProgress>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\3rdPartyLibraries\log4net-2.0.8\bin\net\4.5\release\log4net.dll</HintPath>
</Reference>
<Reference Include="System">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</Reference>
<Reference Include="System.Data">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</Reference>
<Reference Include="System.Drawing">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</Reference>
<Reference Include="System.Windows.Forms">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</Reference>
<Reference Include="System.Xml">
<CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</Reference>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AFile.cpp" />
<ClCompile Include="BFile.cpp" />
<ClCompile Include="Stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="AFile.h" />
<ClInclude Include="BFile.h">
<FileType>CppForm</FileType>
</ClInclude>
<ClInclude Include="resource.h" />
<ClInclude Include="Stdafx.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="app.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties Spices_ObfuscationOptions="{Anonymizer=High}{AntiILDASM=CompleteImproved}{Members=Full}" />
</VisualStudio>
</ProjectExtensions>
</Project>
According to Microsoft C++ CLI projects can't target .Net Standard:
There are some important limitations to porting C++/CLI projects to
.NET Core compared to other languages:
C++/CLI projects can't target .NET Standard, only .NET Core (or .NET
Framework).
See https://learn.microsoft.com/en-us/dotnet/core/porting/cpp-cli
Example repo here - https://github.com/venkatrao-rgare/specflow-vs2019/
After I do clean and build the test are generated in test explorer, when I try to right click on the test and run, it fails.
I looked at the "TestResults" folder to see this in the log, I don't have dotnet.exein C:\Program Files (x86)\dotnet\, not sure where to find it.
Can someone help with this? What should I install / configure to make this test run as expected ?
2020-02-04T12:34:26.0176209-06:00:System.ComponentModel.Win32Exception (2): The system cannot find the file specified.
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at TechTalk.SpecRun.Framework.Execution.OutOfProc.OutProcExecutorManager.StartProcess(ExecutorProcessInfo executorProcessInfo)
at TechTalk.SpecRun.VisualStudio.TestAdapter.VsOutProcExecutorManager.StartProcess(ExecutorProcessInfo executorProcessInfo)```
Stefan Zivkovic - It turned out to be an issue with Processor architecture. I posted this as a bug with Specflow not knowing if it was related to VS2019 or Specflow - the fix suggested in the comment in the bug to change the Processor architecture fixed it for me locally. - https://github.com/SpecFlowOSS/SpecFlow/issues/1877
You have this references in your project:
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="SpecFlow" Version="3.1.82" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.82" />
<PackageReference Include="SpecRun.Runner" Version="3.1.48" />
<PackageReference Include="SpecRun.SpecFlow" Version="3.1.48" />
</ItemGroup>
Please do remove references for Microsoft.NET.Test.Sdk and Newtonsoft.Json, and then run test.
I'm trying to build a F# project (console) on Ubuntu 17.10 (Mono 4.6.2) however I run into F# core .NET issues. For reference, I'm using Visual Studio Code 1.21.2 and ionide extensions (new project and FAKE build). Below is the output.
I've tried adding an explicit reference to different versions of Fsharp.core e.g. 4.2, 4.3.4 with no luck.
Where should I be looking at to sort this out?
Finished Target: InstallDotNetCLI
Starting Target: Restore (==> InstallDotNetCLI)
/home/lear/.local/share/dotnetcore/dotnet restore
Restoring packages for /home/lear/src/fsTest/fsTest/fsTest.fsproj...
/home/lear/src/fsTest/fsTest/fsTest.fsproj : error NU1100: Unable to resolve 'FSharp.Core (>= 4.3.4)' for '.NETFramework,Version=v4.6.1'.
Restore failed in 99.61 ms for /home/lear/src/fsTest/fsTest/fsTest.fsproj.
Running build failed.
<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.3.4" />
</ItemGroup>
The project file looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="fsTest.fsproj">
<Name>fsTest.fsproj</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="fsTest.fs" />
<None Include="App.config" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
I used this instructions as reference for my setup:
Four easy steps for installing F# on Ubuntu Linux (2017-07-03)
The project file specifies the wrong TargetFramework. Changing that to e.g. netcoreapp2.0 Target Framework Moniker should fix the build.
The project you are trying to build/restore is referencing itself. Just remove this portion from the fsproj file:
<ItemGroup>
<ProjectReference Include="fsTest.fsproj">
<Name>fsTest.fsproj</Name>
</ProjectReference>
</ItemGroup>
I'm currently trying to make some progress in learning F# and web development, and to that end I've used Yeoman to generate a F# ASP.NET project to start with (generator).
I've used Bower to install the dependencies, and the project both builds and runs with no issues, in both VS Code and just using dotnet run. However, navigating to the Startup.fs, it claims these namespaces opened aren't defined:
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Logging
In the .fsproj file, the following packages are included, and I have run dotnet restore:
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-beta-*" PrivateAssets="All"/>
<PackageReference Include="Microsoft.AspNetCore" Version="1.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.3"/>
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.2"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.2"/>
<PackageReference Include="Microsoft.FSharp.Core.netcore" Version="1.0.0-alpha-161023"/>
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.1"/>
To my mind, those lines should include at least some of the relevant NuGet packages for the namespace above. I would like to know how to let VS Code see that these namespaces are defined in the packages, and what's currently wrong. Any insight would be appreciated.
Per comments under the question moving my comment to the answer:
I haven't used F# with core however I noticed that you have a reference
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.0-beta-*" PrivateAssets="All"/>
<PackageReference Include="Microsoft.FSharp.Core.netcore" Version="1.0.0-alpha-161023"/>.
I have a .net core 2 preview installed and generating new web project via dotnet command generated reference to
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
which has not issues in VS Code