How to install .Net Framework 4.7 with clickonce/bootstrapper? - c#

I want to install .NEt Framework using bootstrapper/Clickonce application. The code I have used is as shown below -
But it fails with this error -
warning MSB3155: Item 'Microsoft.Net.Framework.4.7.1' could not be located in 'D:\a\1\s\src\ABC\Main'.
Error MSB3147: Could not find required file 'setup.bin' in 'D:\a\1\s\src\ABC\Main\Engine'.
What I want to do is to install .net framework from vendor site and hence the installers are not bundled. Can someone help here ?
<Target Name="BuildBootstrapper">
<ItemGroup>
<BootstrapperFile Include="Microsoft.Net.Framework.4.7.1">
<ProductName>.NET Framework 4.7.1</ProductName>
</BootstrapperFile>
</ItemGroup>
<GenerateBootstrapper
ApplicationFile="ABC.application"
ApplicationName="ABC"
BootstrapperItems="#(BootstrapperFile)"
ComponentsLocation="HomeSite"
/>
</Target>
I am using VS2017

This worked fine for me where it creates setup.exe at the outputpath and redirects user if they dont have framework installed .
<Target Name="BuildBootstrapper">
<PropertyGroup>
<MyPathToPrerequisitePackages>C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper</MyPathToPrerequisitePackages>
<MyDesiredOutputPath>C:\Bootstrapper</MyDesiredOutputPath>
</PropertyGroup>
<ItemGroup>
<BootstrapperFile Include=".NETFramework,Version=v4.7.1">
<ProductName>Microsoft .NET Framework 4.7.1</ProductName>
</BootstrapperFile>
</ItemGroup>
<GenerateBootstrapper
ApplicationFile="ABC.application"
ApplicationName="ABC"
ApplicationUrl=""
BootstrapperItems="#(BootstrapperFile)"
ComponentsLocation="HomeSite"
Path="$(MyPathToPrerequisitePackages)"
OutputPath=""
/>

Related

Project gets unloaded when opening with Visual Studio 2019

I am trying to open a solution using Visual studio 2019 and visual studio 2017. All the projects in the solution are loading except for one. When trying to load the unloaded project i get an error in the output window as
TakstMVC.csproj : error : The imported project
"....build\MSBuild.Community.Tasks.targets" was not found. Confirm
that the expression in the Import declaration
"TakstMVC\.....build\MSBuild.Community.Tasks.targets" is correct,
and that the file exists on disk. TakstMVC\FluentMigrator.targets
When i tried to open using VS 2017 i saw a migration report which said
TakstMVC.csproj: The application which this project type is based on
was not found. Please try this link for further information:
http://go.microsoft.com/fwlink/?LinkID=299083&projecttype=E3E379DF-F4C6-4180-9B81-6769533ABE47
Part of the .csproj of the project is as below:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{A4354F5C-ECF5-4621-AA9E-B91FE543F096}</ProjectGuid>
<ProjectTypeGuids>{E3E379DF-F4C6-4180-9B81-6769533ABE47};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TakstMVC</RootNamespace>
<AssemblyName>TakstMVC</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<UseIISExpress>true</UseIISExpress>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<FileUpgradeFlags>
</FileUpgradeFlags>
<UpgradeBackupLocation>
</UpgradeBackupLocation>
<OldToolsVersion>4.0</OldToolsVersion>
<IISExpressSSLPort />
<IISExpressAnonymousAuthentication />
<IISExpressWindowsAuthentication />
<IISExpressUseClassicPipelineMode />
<MvcProjectUpgradeChecked>true</MvcProjectUpgradeChecked>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
I have the following installed in my computer
Microsoft .NET Framework 4.7.1 SDK
Microsoft .NET Framework 4.7.1 SDK Targeting Pack (ENU)
Microsoft .NET Core 3.1.1 - Windowsserver hosting
Microsoft .NET Core SDK 3.1.101 (x64)
Microsoft .NET Core SDK 2.2.207 (x64)
Microsoft .NET Core Runtime - 3.1.1
Microsoft .NET Core Runtime - 2.2.8
I tried to install dotnetfx35.exe but it doesnt even run when executed (not even a message or error).
The windows feature are as below:
How can I identify the target framework of the project and load it in visual studio successfully ? appreciate some advise on this.
The error is clear that you did not import the MSBuild.Community.Tasks.targets correctly on your local area. The reason is that you did not install MSBuild.Community.Tasks.targets on your PC or the import path from csproj file is incorrect.
You should check this document to install the right target.
First, remove xml node under csproj file like these:
<Import Project="..\build\MSBuild.Community.Tasks.targets" Condition="Exists('..\build\MSBuild.Community.Tasks.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\build\MSBuild.Community.Tasks.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\build\MSBuild.Community.Tasks.targets'))" />
</Target>
Second, install the msi file.
then, add these under the csproj file:
<Import Project="C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
Besides, you could also use nuget function. First, uninstall the nuget package if you have a old version on the project. Then, use the first suggestion to remove any previous import projects="xxx\MSBuildTasks.targets". After that, install the MSBuildTasks nuget package. That is the same.
Update
Try to You should change ..\..\ to ..\. Use the right path.
Or use this command under Tools-->Nuget Package Manager-->Package Manager Console
update-package -reinstall
Answer from the Customer
embarrassingly enough the whole issue was with the solution path where my solution was located in my local computer. I had a long path including a folder having two words as well. After trying everything else I moved the solution folder to C:\temp folder and the issue was no longer there. The error showed in VS was quite misleading. What a waist of time. Thank you for your efforts !

DotNetCore3.0 WPF - error - Project file is incomplete. Expected imports are missing

I've created a WPF application using VisualStudio 2017 by selecting the .Net framework 4.6. Know I'm trying to configure it for .Net Core 3.0 for WPF. But unfortunately, after changing my configuration, When reloading my projects, I got this error.
Project file is incomplete. Expected imports are missing.
I've checked all the reference files are there.
Here is my .csproj file.
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AssemblyName>HelloWorld</AssemblyName>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<ApplicationDefinition Include="..\WpfApp\App.xaml" Link="App.xaml" />
<Compile Include="..\WpfApp\App.xaml.cs" Link="App.xaml.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="..\WpfApp\MainWindow.xaml" Link="MainWindow.xaml" />
<Compile Include="..\WpfApp\MainWindow.xaml.cs" Link="MainWindow.xaml.cs" />
</ItemGroup>
</Project>
I've installed this SDK version 3.0.100-preview5-011568. I've also enabled the Use previews of .Net Core SDK in VisualStudio.
You should upgrade to Visual Studio 2019. It includes a project template for WPF and Windows Forms applications targeting .NET Core 3.
From the docs:
Visual Studio 2017 doesn't support .NET Core 3.0 projects.

The specified framework 'Microsoft.NETCore.App', version '2.1' was not found

I am developing an Angular 6 application in dotNet Core 2.1.
Everything is working flawlessly, until I got to setting up EFCore.
All my models are defined and context created. Running dotnet ef migrations add InitialCreate gives me the "The specified framework 'Microsoft.NETCore.App', version '2.1' was not found" error.
I have searched and read all the posts I could find that has this error across various versions of dotNet Core. Nothing is working to resolve this issue for me.
I have various versions of dotNet Core App installed.
Looking at "C:\Program Files\dotnet\shared\Microsoft.NETCore.App" I have the following:
-1.0.4
-1.0.5
-1.1.1
-1.1.2
-2.0.0
-2.0.3
-2.0.5
-2.0.6
-2.0.7
-2.0.9
-2.1.0
-2.1.4
-2.1.5
-2.1.6
"C:\Program Files\dotnet" appears as the first path in my System PATH variable.
Downgrading all the projects in my solution to dotNet Core 2.0, running the command results in exactly the same error, referring to version 2.0.
Any advise would be greatly appreciated...
The csproj file for my EF project is as follows:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\*********.Contracts\*********.Contracts.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System">
<HintPath>System</HintPath>
</Reference>
<Reference Include="System.Data">
<HintPath>System.Data</HintPath>
</Reference>
<Reference Include="System.Xml">
<HintPath>System.Xml</HintPath>
</Reference>
</ItemGroup>
</Project>
To solve the issue, I had to install the Microsoft.EntityFrameworkCore.Design package. The installing-the-tools section of the documentation states that it is not necessary to do so for Asp.Net Core 2.1+:
ASP.NET Core 2.1+
Install the current .NET Core SDK. The SDK has to be installed even if you have the latest version of Visual Studio 2017.
This is all that is needed for ASP.NET Core 2.1+ because the Microsoft.EntityFrameworkCore.Design package is included in the Microsoft.AspNetCore.App metapackage.
My solution is broken up into different projects; I created a Class Library project where my EF Core installation resides.
Since it is not an Asp.Net Core project (It's a Class Library as stated before), it also required the Microsoft.EntityFrameworkCore.Design package to be installed.
The package can be installed using: dotnet add package Microsoft.EntityFrameworkCore.Design
Thanks to Ivan Stoev for pointing me in the direction of the documentation.
The error was no help at all, sending me on a wild goose chase to try and find the underlying problem. I hope this will be useful to someone else.
I have the same issue when running
dotnet ef dbcontext info -s ProjectWeb.csproj
Although the version it is looking is 2.1.17:
The framework 'Microsoft.NETCore.App', version '2.1.17' was not found.
Fortunately, upon digging into the issue, there was a suggestion to download it here:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.1.17&arch=x64&rid=win10-x64
Which will redirect you to this link:
https://dotnet.microsoft.com/download/dotnet-core/2.1/runtime/?utm_source=getdotnetcore&utm_medium=referral
After installation, the issue was fixed on my side.
Please also check your BundlerMinifier:
<ItemGroup>
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="3.2.449" />
</ItemGroup>
If you are using an older version, that is likely the culprit... see latest versions here:
https://www.nuget.org/packages/BundlerMinifier.Core/

Error when building System.ValueTuple in .NetStandard 2.0 project

I have a .NetStandard project that uses System.ValueTuple.
It builds fine in visual studio whether or not I include the System.ValueTuple nuget package.
However it fails either way when I build it on team-city with the error:
error CS8137: Cannot define a class or member that utilizes tuples because the compiler required type 'System.Runtime.CompilerServices.TupleElementNamesAttribute' cannot be found. Are you missing a reference?
Teamcity is hosted on an environment with both the latest .Net Core SDK and the latest .NetFramework SDK.
When I change the target framework to .NetCoreApp2.0 it builds fine.
Any ideas as to what could be going on?
For Reference, here is my csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>$(VersionSuffix)</Version>
<Authors>**********</Authors>
<Product>**********</Product>
<Description>**********</Description>
<PackageTags>**********</PackageTags>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<Copyright>**********</Copyright>
<PackageProjectUrl>http://**********</PackageProjectUrl>
<PackageLicenseUrl>http://**********</PackageLicenseUrl>
<PackageIconUrl>http://**********</PackageIconUrl>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.4.1" />
<PackageReference Include="RabbitMQ.Client" Version="5.0.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="**********" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\**********" />
</ItemGroup>
The error went away when I started using DotNet Restore instead of Nuget Restore.
I have no idea why.
You most probably need to add a reference to System.ValueTuple.dll. You can do this by installing the System.ValueTuple package from nuget.

Migrate .csproj from .NET Framework 4.5 to .NET Core 2.1.1

I have a .NET Core 2.1.1 project, and I am trying to copy the contents from an existing .NET Framework 4.5 project by updating the .csproj file.
I guess there are many different parts that wont't work on a .NET Core 2.1.1 project.
So my main question is how to migrate a .csproj file from .NET Framework 4.5 to .NET Core 2.1.1.
The first thing I need to do is to copy the contents from one project to another:
This is a working .NET Framework 4.5 .csproj line that does exactly that:
<Target Name="BeforeBuild">
<PropertyGroup>
<GeneratedMigrationFile>$(IntermediateOutputPath)Migrations.Generated.cs</GeneratedMigrationFile>
</PropertyGroup>
<ItemGroup>
<SqlFiles Include="Data\*.sql" />
<Compile Condition="'#(SqlFiles)' != ''" Include="$(GeneratedMigrationFile)" />
<EmbeddedResource Include="#(SqlFiles)" />
<None Include="..\..\_libBinary\FluentMigrator.1.1.1.0\tools\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<MakeDir Directories="$(IntermediateOutputPath)" />
<Delete Files="$(GeneratedMigrationFile)" />
<GenerateMigration Condition="'#(SqlFiles)' != ''" Namespace="$(RootNamespace)" Id="%(SqlFiles.Filename)" FileId="%(SqlFiles.Filename)" Output="$(GeneratedMigrationFile)" />
</Target>
...
....
However, when doing the same in a .NET Core 2.1.1 .csproj, it seems not to be working and the content of the folder is not being copied.
I deleted the following line because it was causing a build error:
<GeneratedMigrationFile>$(IntermediateOutputPath)Migrations.Generated.cs</GeneratedMigrationFile>
How can I migrate the .csproj file?

Categories