Can't install IdentityServer4.Template - identityserver4

Why I can't install IdentityServer4 template using dotnet new --install IdentityServer4.Templates::4.0.1?
When I run the command it does not show any errors, it just shows the list of templates I have.
I checked my Windows user NuGet configuration and there seems nothing wrong with it.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear/>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="IdentityServer Local" value="./nuget" />
</packageSources>
</configuration>
I've also tried using this command dotnet new -i identityserver4.templates --nuget-source https://api.nuget.org/v3/index.jsonbut it does not work either.

I still didn't have the solution to the problem but I found a workaround by downloading the nuget package file of the IdentityServer Template. Then I run dotnet new -i <path>\identityserver4.templates.4.0.1.nupkg.

Check the path (eg. 'C:\Users\username.templateengine\packages' for windows) where the identityserver4.template already exist and delete it. You can now install idp.

Related

It is possible to use new csproj format to build for .NET Framework Client Profile?

I am trying to manually update a new csproj file to configure building for .NET Framework 4.0 Client Profile.
This works correctly
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>NET40</TargetFrameworks>
</PropertyGroup>
</Project>
but this generates an error
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>NET40</TargetFrameworks>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup>
</Project>
'project.assets.json' doesn't have a target for
'.NETFramework,Version=v4.0,Profile=Client'.
Ensure that restore has run and that you have included
'net40-client' in the TargetFrameworks for your project.
Is it possible to use new csproj format e.g. <Project Sdk="Microsoft.NET.Sdk"> to build for .NET Framework Client Profile?
This worked for me:
<TargetFramework>net40-client</TargetFramework>
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
There is a package for this, all you have to do is to replace the first line of your csproj with:
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
Then you have some new target frameworks available such as net40-client, so
<TargetFrameworks>net40-client</TargetFrameworks>
will now work.
See the project page (https://github.com/novotnyllc/MSBuildSdkExtras) if you want more information.

DACPAC Deployment setting

I want to publish my dacpac file using VSTS. I will be giving only DACPAC file to Dev ops team. I want to ignore drop table that is not in source. If i Publish it from SSDT, I can change in advanced settings. How to do that for VSTS. I can see an option under debug menu, But I am unable to check that option, Screen shot is attached in below URL.
https://i.stack.imgur.com/TBQPe.png
You can give publish.xml along side your dacpac and include a similar setting in that xml as well such as mentioned below
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IncludeCompositeObjects>True</IncludeCompositeObjects>
<TargetDatabaseName>dbname</TargetDatabaseName>
<DeployScriptFileName>dbname.sql</DeployScriptFileName>
<TargetConnectionString>Data Source=<name>;Integrated Security=True;Persist
Security Info=False;Pooling=False;MultipleActiveResultSets=False;Connect
Timeout=60;Encrypt=False;TrustServerCertificate=True</TargetConnectionString>
<BlockOnPossibleDataLoss>False</BlockOnPossibleDataLoss>
<DropObjectsNotInSource>False</DropObjectsNotInSource>
<ProfileVersionNumber>1</ProfileVersionNumber>
</PropertyGroup>
<ItemGroup>
</ItemGroup>
</Project>
and while deploying dacpac (using cmd or powershell) you need to pass this xml file path in /Profile: parameter to pick this xml for deployment settings

FSharp.Data.SqlClient on windows with dotnet core reports type 'SqlCommand' unavailable

I'm trying to use FSharp.Data.SqlClient on Windows
c:\...> dotnet new console -lang f# -o test5
c:\...> cd test5
Now add <Import Project="fsc.props" /> to test5.fsproj and add fsc.props from https://raw.githubusercontent.com/fsprojects/FSharp.TypeProviders.SDK/master/fsc.props. Then
c:\...\test5> dotnet add package FSharp.Data.SqlClient
And edit Program.fs as follows:
open FSharp.Data
open FSharp.Data.SqlClient
[<Literal>]
let connectionString =
#"Data Source=.\SQL14X64;Initial Catalog=test;User=sa;Password=***"
[<EntryPoint>]
let main argv =
use cmd = new SqlCommandProvider<"
SELECT 1
" , connectionString>(connectionString)
0
Trying to compile it:
c:\...\test5> dotnet build
Have error:
The type 'SqlCommand' is required here and is unavailable.
You must add a reference to assembly 'System.Data.SqlClient, Version=0.0.0.0, ...
Ok, installing System.Data.SqlClient:
c:\...\test5> dotnet add package System.Data.SqlClient
Have error:
The type 'SqlCommand' is required here and is unavailable.
You must add a reference to assembly 'System.Data.SqlClient, Version=4.2.0.1, ...
O-key, let install 4.2.0.1:
c:\...\test5> dotnet remove package System.Data.SqlClient
c:\...\test5> dotnet add package System.Data.SqlClient --version 4.2.0.1
c:\...\test5> dotnet build
Have error:
The type 'SqlCommand' is required here and is unavailable.
You must add a reference to assembly 'System.Data.SqlClient, Version=4.1.0.0, ...
Hm... Replace with 4.1.0.0:
c:\...\test5> dotnet remove package System.Data.SqlClient
c:\...\test5> dotnet add package System.Data.SqlClient --version 4.1.0.0
c:\...\test5> dotnet build
Have same error again:
The type 'SqlCommand' is required here and is unavailable.
You must add a reference to assembly 'System.Data.SqlClient, Version=4.1.0.0, ...
Cannot really move any further with it.
OS: Windows, .NET Core: 2.1.2
I'm sure others are still struggling with this from time to time, so here is what I had to do in order to get the FSharp.Data.SqlClient running in a .NET Core project on a Mac (yes, it does work, beautifully!).
I believe most of it will apply to Windows as well, except that you won't need Mono.
At compile time you need full .NET framework, so you have to install Mono if you are running Linux or Mac. The project still compiles to clean .NET Core.
You need fsc.props in your project folder (place it in the same folder as your project file). Fsc.props contains the path to the tool to use at compile time. In my fsc.props file the relevant path was described as follows (I can't remember whether or not I had to edit it to get things running):
<PropertyGroup Condition="'$(IsOSX)' == 'true' AND Exists('/Library/Frameworks/Mono.framework/Versions/Current/Commands/fsharpc')">
<FscToolPath>/Library/Frameworks/Mono.framework/Versions/Current/Commands</FscToolPath>
<FscToolExe>fsharpc</FscToolExe>
</PropertyGroup>
Next you need to reference fsc.props in your .fsproj file, and DisableAutoSetFscCompilerPath:
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="fsc.props" />
<PropertyGroup>
<DisableAutoSetFscCompilerPath>true</DisableAutoSetFscCompilerPath>
<DotNetFscToolPath></DotNetFscToolPath>
<DotnetFscCompilerPath></DotnetFscCompilerPath>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="mySQLCode.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Data" Version="3.3.3" />
<PackageReference Include="FSharp.Data.SqlClient" Version="2.0.6" />
</ItemGroup>
</Project>
The relevant lines are lines 2 through 8.
Of course you also have to get the Fsharp.Data and FSharp.Data.SqlClient using your favourite package manager, which will add the PackageReference lines to the project.
Happy coding
Roland

NuGet does not add dependencies to package

I'm trying to package my WPF application with the NuGet pack command. So far I found out that adding -IncludeReferencedProjects resolves the problem of referenced projects not getting packed.
./nuget.exe pack {path}.csproj -NonInteractive -OutputDirectory C:\test -Properties Configuration=release -version 0.1.0 -Verbosity Detailed -IncludeReferencedProjects
The problem I face is that the project's dependencies are not getting packed. They however do show up in the log as you can see below. Dependencies: EntityFramework.
But the dependencies are never added to the package. Even when I manually inspect or deploy the package only Data.dll and {name}.exe are deployed.
What I've already tried (by searching Google/SO):
Adding a NuSpec file for the csproj file
NuGet.config with a reference to the correct packages folder (in case NuGet did not find it)
EDIT: added generated .nuspec
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>{path}.UpgradeDatabase</id>
<version>0.1.4</version>
<title>{path}.UpgradeDatabase</title>
<authors>stephanbisschop</authors>
<owners>stephanbisschop</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Description</description>
<copyright>Copyright © 2016</copyright>
<dependencies>
<dependency id="EntityFramework" version="6.1.3" />
</dependencies>
</metadata>
</package>
Thank you in advance,
Stephan
Problem solved.
It wasn't my NuGet package that was missing the dependencies.. it was Octopus Deploy that wasn't restoring the packages. We fixed it by adding entries in the appropriate .NuSpec files. Now all the .dll, .config , etc.. files get packaged with the package.

Install nuget package to a custom folder

I have created an ASP.NET 5 app in Visual Studio Community Edition. Then I tried to install the nugget package angularjs.TypeScript.DefinitelyTyped using the command Install-Package angularjs.TypeScript.DefinitelyTyped as well as through the NuGet Package Manager. Both these commands dropped the package in the C:\Users\john\.dnx\packages folder.
I changed the repositoryPath in the nuget.config. Still the packages are saved in the same folders and not under the project.
How can I save the nuget packages under the project and not under c:\users.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<config>
<add key="repositoryPath" value="C:\Projects\HelloWorld\src\Scripts"/>
</config>
</configuration>
This is where the packages are dropped.
C:\Users\john\.dnx\packages\angularjs.TypeScript.DefinitelyTyped\4.2.8
But I want it under C:\Projects\HelloWorld\src
This is part of the not very well documented global.json. This global.json file creates a packages sub dir relative to it, where all the nuget packages end up when you restore them.
{
"packages": "packages",
"sdk": {
"version": "1.0.0-beta8",
"runtime": "coreclr",
"architecture": "x64"
}
}

Resources