Invalid framework identifier Dotnet restore, docker build - c#

i'm having this error when i try to run docker build in my dotnet core API:
Invalid framework identifier ''
Here is my dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY Backend/AppManagerAPI/AppManagerAPI.csproj Backend/AppManagerAPI/
COPY Backend/DTO/DTO.csproj Backend/DTO/
COPY nuget.config ./
COPY Build/dependencies.props ./Build
COPY Backend/Database/Database.csproj Backend/Database/
COPY Backend/Service/Service.csproj Backend/Service/
COPY Utilities/Utilities.csproj Utilities/
RUN dotnet restore "Backend/AppManagerAPI/AppManagerAPI.csproj"
COPY . .
WORKDIR "/src/Backend/AppManagerAPI"
RUN dotnet build "AppManagerAPI.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "AppManagerAPI.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "AppManagerAPI.dll"]
and the full error stack:
$ docker build -t appmanager .
Sending build context to Docker daemon 560.6kB
Step 1/23 : FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
---> 34973cab5999
Step 2/23 : WORKDIR /app
---> Using cache
---> c402eb945a47
Step 3/23 : EXPOSE 80
---> Using cache
---> 8ac4a84a040e
Step 4/23 : EXPOSE 443
---> Using cache
---> 3c5014f9b6d5
Step 5/23 : FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
---> 08657316a4cd
Step 6/23 : WORKDIR /src
---> Using cache
---> e851dfaa1225
Step 7/23 : COPY Backend/AppManagerAPI/AppManagerAPI.csproj Backend/AppManagerAPI/
---> Using cache
---> 1eaa1d28c559
Step 8/23 : COPY Backend/DTO/DTO.csproj Backend/DTO/
---> Using cache
---> 81f9260e48a0
Step 9/23 : COPY nuget.config ./
---> Using cache
---> 3901e5ab8090
Step 10/23 : COPY Build/dependencies.props ./Build
---> Using cache
---> 35128353acde
Step 11/23 : COPY Backend/Database/Database.csproj Backend/Database/
---> Using cache
---> 25686efb1af9
Step 12/23 : COPY Backend/Service/Service.csproj Backend/Service/
---> Using cache
---> 3287a7a78971
Step 13/23 : COPY Utilities/Utilities.csproj Utilities/
---> Using cache
---> fe57c187d929
Step 14/23 : RUN dotnet restore "Backend/AppManagerAPI/AppManagerAPI.csproj"
---> Running in 33780f69aa7d
/usr/share/dotnet/sdk/2.2.401/NuGet.targets(123,5): error : Invalid framework identifier ''. [/src/Backend/AppManagerAPI/AppManagerAPI.csproj]
The command '/bin/sh -c dotnet restore "Backend/AppManagerAPI/AppManagerAPI.csproj"' returned a non-zero code: 1
I've already tried everything that i could think of, i was wondering if it has anything to do with my properties.props file, but copying it to the container didn't work. Any help would be appreciated.
UPDATE
Here's is my AppManagerAPI.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>$(NetCoreTargetVersion)</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<UserSecretsId>d37c9296-55fb-4c04-ad4e-3d1f5451dc28</UserSecretsId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<NoWarn></NoWarn>
<AllowUnsafeBlocks></AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<None Remove="API.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Alpha.WebUtils.Core" Version="$(AlphaWebUtilsCorePackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.App">
<PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
</PackageReference>
<PackageReference Include="Alpha.Utils.Core" Version="$(AlphaUtilsCorePackageVersion)" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutomapperDIPackageVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.4.10" />
<PackageReference Include="Scrutor" Version="$(ScrutorPackageVersion)" />
<PackageReference Include="Alpha.Backend.Core" Version="$(AlphaBackendCorePackageVersion)" />
<PackageReference Include="Alpha.Backend.EFCore" Version="$(AlphaBackendEFCorePackageVersion)" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="$(SwashbuckleAspNetCorePackageVersion)" />
<PackageReference Include="NetEscapades.Extensions.Logging.RollingFile" Version="$(LoggingRollingFilePackageVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Api.Analyzers" Version="$(ApiAnalyzersPackageVersion)" />
<PackageReference Include="EfCore.GenericBizRunner" Version="$(EfCoreGenericBizRunnerPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DTO\DTO.csproj" />
<ProjectReference Include="..\Service\Service.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\" />
<Folder Include="wwwroot\Upload\" />
<Folder Include="logs\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Controllers\Administracion\RutasController.cs" />
<Compile Remove="Controllers\Administracion\SectoresController.cs" />
<Compile Remove="Controllers\Administracion\ConsultaRutasController.cs" />
<Compile Remove="Controllers\Administracion\ComercioEntidadTipoClienteController.cs" />
<Compile Remove="Controllers\Administracion\LugaresController.cs" />
<Compile Remove="Controllers\Genericos\CentrosController.cs" />
<Compile Remove="Controllers\Genericos\MenuController.cs" />
<Compile Remove="Controllers\GestionIntervenciones\AlisysController.cs" />
<Compile Remove="Controllers\GestionIntervenciones\OrdenesIntervencionesController.cs" />
<Compile Remove="Controllers\GestionIntervenciones\SauController.cs" />
<Compile Remove="Controllers\Genericos\SystemController.cs" />
<Compile Remove="Controllers\Mantenimiento\AccesoriosController.cs" />
<Compile Remove="Controllers\Mantenimiento\DiasFestivosController.cs" />
<Compile Remove="Controllers\Mantenimiento\EemmsController.cs" />
<Compile Remove="Controllers\Mantenimiento\EntidadesMantenedorasController.cs" />
<Compile Remove="Controllers\Mantenimiento\EtiquetasSatController.cs" />
<Compile Remove="Controllers\Mantenimiento\GruposCualificadoresController.cs" />
<Compile Remove="Controllers\Mantenimiento\HorariosController.cs" />
<Compile Remove="Controllers\Mantenimiento\IncidenciasController.cs" />
<Compile Remove="Controllers\Mantenimiento\MarcasController.cs" />
<Compile Remove="Controllers\Mantenimiento\ModelosController.cs" />
<Compile Remove="Controllers\Mantenimiento\ModelosIndicadosController.cs" />
<Compile Remove="Controllers\Mantenimiento\MotivoCierreController.cs" />
<Compile Remove="Controllers\Mantenimiento\MotivosParadaController.cs" />
<Compile Remove="Controllers\Mantenimiento\PatronesCentroController.cs" />
<Compile Remove="Controllers\Mantenimiento\PerfilesUsuarioController.cs" />
<Compile Remove="Controllers\Mantenimiento\PermisosController.cs" />
<Compile Remove="Controllers\Mantenimiento\PiezaAlmacenPrecioController.cs" />
<Compile Remove="Controllers\Mantenimiento\PiezasController.cs" />
<Compile Remove="Controllers\Mantenimiento\SoftwaresController.cs" />
<Compile Remove="Controllers\Mantenimiento\TecnologiasController.cs" />
<Compile Remove="Controllers\Mantenimiento\TipoActualizacionController.cs" />
<Compile Remove="Controllers\Mantenimiento\TipoIncidenciaController.cs" />
<Compile Remove="Controllers\Mantenimiento\TipoIntervencionController.cs" />
<Compile Remove="Controllers\Mantenimiento\TiposClientesController.cs" />
<Compile Remove="Controllers\Mantenimiento\TiposCoberturasController.cs" />
<Compile Remove="Controllers\Mantenimiento\TiposLugarController.cs" />
<Compile Remove="Controllers\Mantenimiento\TiposMantenimientoController.cs" />
<Compile Remove="Controllers\Mantenimiento\TiposModoTerminalController.cs" />
<Compile Remove="Controllers\Mantenimiento\TiposSeguridadTerminalController.cs" />
<Compile Remove="Controllers\Mantenimiento\TiposTecnologiaController.cs" />
<Compile Remove="Controllers\Mantenimiento\TiposTerminalController.cs" />
<Compile Remove="Controllers\Administracion\DelegacionesController.cs" />
<Compile Remove="Controllers\Administracion\ListasCorreoController.cs" />
<Compile Remove="Controllers\Genericos\CodigosPostalesController.cs" />
<Compile Remove="Controllers\Genericos\MotivoTipoEntidadController.cs" />
<Compile Remove="Controllers\Genericos\PrioridadesController.cs" />
<Compile Remove="Controllers\GestionIntervenciones\BloqueosController.cs" />
<Compile Remove="Controllers\GestionIntervenciones\EstadosIntervencionController.cs" />
<Compile Remove="Controllers\GestionIntervenciones\EstadosOdinController.cs" />
<Compile Remove="Controllers\Mantenimiento\Configuracion\CalendarioLaboralesController.cs" />
<Compile Remove="Controllers\Mantenimiento\Configuracion\NotificacionesEmailController.cs" />
<Compile Remove="Controllers\Mantenimiento\AccionesController.cs" />
</ItemGroup>
</Project>

The problem was that i needed to copy my Directory.Build.props file and now is working. Just added this line to my dockerfile
COPY Directory.Build.props ./

Related

Smarter File nesting inside csproj wildcard

I need better file nesting.
I have Index.razor, Index.razor.cs, Index.Model.cs, Index.Interface.cs inside the Pages folder.
In csproj
I have
<ItemGroup>
<Compile Update="Pages\Index.razor.cs" DependentUpon="Pages\Index.razor" />
<Compile Update="Pages\Index.Model.cs" DependentUpon="Pages\Index.razor" />
<Compile Update="Pages\Index.Interface.cs" DependentUpon="Pages\Index.razor" />
</ItemGroup>
I created this functionality into Wildcard
<ItemGroup>
<Compile Update="**\*.Interface.cs" DependentUpon="$([System.String]::Copy('%(FileName)').Replace('.Interface', '.razor'))" />
<Compile Update="**\*.Model.cs" DependentUpon="$([System.String]::Copy('%(FileName)').Replace('.Model', '.razor'))" />
</ItemGroup>
What I want is better version of this
<ItemGroup>
<Compile Update="**\*.Interface.cs" Condition="Exists('Check Razor')" >
<DependentUpon>"$([System.String]::Copy('%(FileName)').Replace('.Interface', '.razor'))"</DependentUpon>
</Compile>
<Compile Update="**\*.Model.cs" Condition="Exists('Check Razor')" >
<DependentUpon>"$([System.String]::Copy('%(FileName)').Replace('.Model', '.razor'))"</DependentUpon>
</Compile>
<Compile Update="**\*.Interface.cs" Condition="Exists('Check cshtml')" >
<DependentUpon>"$([System.String]::Copy('%(FileName)').Replace('.Interface', '.cshtml'))"</DependentUpon>
</Compile>
<Compile Update="**\*.Model.cs" Condition="Exists('Check cshtml')" >
<DependentUpon>"$([System.String]::Copy('%(FileName)').Replace('.Model', '.cshtml'))"</DependentUpon>
</Compile>
Need to check here also
<Compile Update="**\*.Interface.cs" DependentUpon="$([System.String]::Copy('%(FileName)').Replace('.Interface', '.cs'))" />
<Compile Update="**\*.Model.cs" DependentUpon="$([System.String]::Copy('%(FileName)').Replace('.Model', '.cs'))" />
</ItemGroup>
So that I can use Isolation in cshtml and razor project without hasle.
For example to work in xaml, you can use MSBuild15's static update syntax.
<Compile Update="**\*.xaml.cs" DependentUpon="%(Filename)" />
MSbuild splits paths into ( => ) and ( => ), so it can be used to reference xaml files.
Filenamefoo.xaml.csfoo.xamlExtensionfoo.xaml.cs.cs%(Filename)

WPF Desktop App using MSIX installer - Directory Not Found

I am working with a client to deploy a WPF application using Blazor Desktop. We have a couple of resources the application needs in order to run. I have them specified in an item group like so:
<ItemGroup>
<Content Update="wwwroot\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
It works fine when running the WPF directly in debug mode, but if I run through my MSIX installer I get a directory not found exception because it is looking for the folder that contains those resources inside of C:\Windows\System32. I feel like I am missing something in the appxmanifest, which is below
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity
Name="0f515ea1-7f17-43cd-949f-2ddde5e8176a"
Publisher="CN=SampleCo"
Version="1.0.0.0" />
<Properties>
<DisplayName>CompanyPortal.Installer</DisplayName>
<PublisherDisplayName>SampleCo</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.14393.0" MaxVersionTested="10.0.14393.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="My App"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png" Description="Admin Portal for the TallyIO System">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>
Also here is my csproj for the msix project
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|AnyCPU">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|AnyCPU">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>0d34caa9-b40d-4e58-9045-11d2bcfb4e9d</ProjectGuid>
<TargetPlatformVersion>10.0.22000.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<NoWarn>$(NoWarn);NU1702</NoWarn>
<EntryPointProjectUniqueName>..\CompanyPortal.Desktop\CompanyPortal.Desktop.csproj</EntryPointProjectUniqueName>
<PackageCertificateThumbprint>66AD090A86AB81268A60B29B3FE0455B5E09446A</PackageCertificateThumbprint>
<PackageCertificateKeyFile>CompanyPortal.Installer_TemporaryKey.pfx</PackageCertificateKeyFile>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<None Include="CompanyPortal.Installer_TemporaryKey.pfx" />
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CompanyPortal.Desktop\CompanyPortal.Desktop.csproj" />
</ItemGroup>
</Project>
Is there something I am missing or is it possible to deploy a Blazor Desktop Application using MSIX?
Thank You,
I suspect this is happening because that folder is not virtualized by the OS, when packaged inside the MSIX.
As I explain in this article, only a certain list of system folders are virtualized by the MSIX container, the list provided by Microsoft is included in the article.
Any other folder must be either copied from the install location to the real location at first launch, or (if you need read-only access) you use PSF to redirect the API calls and serve it from your install path.
What I recommend to you:
launch a CMD inside the MSIX container context and run a dir on the install folder (ProgramFiles\WindowsApps\yourapp) to see if the files are actually installed on the machine
if they are there, copy them manually in the IIS wwwroot folder and try running the application again. If this works, it means you need to automate this copy at first launch of your app.
If not, then you need to use the PSF to redirect API calls (read-only) to load the resources from the install location (WindowsApps folder).

.NET Azure Functions - Dependency Injection Issue

On Startup.cs in my Azure Function v2 project:
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using MyCompany.MyLib.Contracts; //namespace from external library
[assembly: FunctionsStartup(typeof(Startup))]
namespace Test
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddTransient(typeof(Logging.ILogger<>), typeof(Logging.Logger<>));
builder.Services.AddTransient<IUserLogic, UserLogic>();
builder.Services.AddTransient<IBillingLogic, BillingLogic>(); //---> loads up from above referenced "MyCompany.MyLib.Contracts" namespace and this namespace is from externally referenced class library but with in same solution
}
}
}
The above code with my own custom classes within function app project like "EmailLogic", "Logger" works fine.
But the moment I added up custom classes to services container like "BillingLogic" from external C# library project which is added as reference project from the existing visual studio solution it throws up below issue:
"A host error has occurred during startup operation '945918c0-af3a-4d50-ab1d-ac405d4f1c7b'. [2/3/2020 2:11:02 PM] MyFunction.FunctionApp: Could not load file or assembly 'MyCompany.MyLib.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly ''MyCompany.MyLib.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
If these lines from "referenced external projects" are removed,
using MyCompany.MyLib.Contracts;
builder.Services.AddTransient<IBillingLogic, BillingLogic>();
startup.cs works as expected but referring this external class from referenced project is must for my solution.
My Azure function csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Azure.Storage.Queue" Version="11.1.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.8" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
<PackageReference Include="NLog" Version="4.6.8" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog.Extensions.AzureStorage" Version="1.1.4" />
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.9.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyCSharpLib.DataStore\MyCSharpLib.DataStore.csproj">
<Private>true</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
<None Update="nlog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
MyCSharpLib.DataStore.csproj file:
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<Platforms>x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos.Table" Version="1.0.6" />
<PackageReference Include="Microsoft.Azure.DocumentDB.Core" Version="2.9.2" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.1" />
<PackageReference Include="Polly" Version="5.3.1" />
<PackageReference Include="StackExchange.Redis" Version="1.2.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyContractLib.Contracts\MyContractLib.Contracts.csproj" />
</ItemGroup>
</Project>
MyCSharpLib.DataStore
.\MyContractLib.Contracts\MyContractLib.Contracts.csproj
My Azure function csproj file:
<ProjectReference Include="..\MyCSharpLib.DataStore\MyCSharpLib.DataStore.csproj">
so
using MyCompany.MyLib.Contracts;
is coming through the ref to DataStore which then has ref to MyContractLib.Contracts
But it is not coping the dll as its silly, so either get Azure function csproj to ref MyLib.Contracts
or do this
How to set dependencies when I use .NET Standard 2.0 DLL libraries with a .NET Framework console application?
which is on all your std libs add
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
so on both your standard libs
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
if this does not work i will delete

Roslyn project.Documents is empty when run on Build server

I have a unit Test that checks that all my service methods make a call to some authorization method.
I'm checking this in a unit Test using Roslyn.
The test runs fine on my local machine but fails on the build server, because project.Documents is empty.
I'm using VS 2017 and mstest V2.
The build server is a private on prem build agent in VSTS.
[TestMethod]
public async Task All_public_Service_Methods_should_check_authorization()
{
var workspace = MSBuildWorkspace.Create();
var project = await workspace.OpenProjectAsync(pathToCsprojFile).ConfigureAwait(false);
Console.WriteLine($"AssemblyName is {project.AssemblyName}"); // same output
Console.WriteLine($"FilePath is {project.FilePath}"); // same output
Console.WriteLine($"Documents are {string.Join(Environment.NewLine,project.Documents.Select(d => d.FilePath))}"); // empty on build server
//...
}
This is the csproj, that I'm trying to load
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.5</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DocumentationFile>bin\Debug\netstandard1.5\adremes.Exchange.Services.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<DocumentationFile>bin\Release\netstandard1.5\adremes.Exchange.Services.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="adremes.Common" Version="1.4.0" />
<PackageReference Include="AutoMapper" Version="5.2.0" />
<PackageReference Include="AutoMapper.Collection" Version="2.1.2" />
<PackageReference Include="DocumentFormat.OpenXml" Version="2.7.1" />
<PackageReference Include="Microsoft.AspNetCore.Authorization" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="1.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\adremes.Exchange.Common\adremes.Exchange.Common.csproj" />
<ProjectReference Include="..\adremes.Exchange.Data\adremes.Exchange.Data.csproj" />
</ItemGroup>
</Project>

ms build dynamic resource naming

I want to add some files to embedded resourses at compile time with special naming. For this I wrote in .csproj
<Target Name="BeforeBuild" >
<ItemGroup>
<EmbeddedResource Include="..\Bin\$(Configuration)\*.*">
</EmbeddedResource>
</ItemGroup>
</Target>
But it always set <LogicalName> to default.
How can I do this?
I found solution. This renaming works:
<Target Name="BeforeBuild">
<ItemGroup>
<Frameworks Include="..\Bin\$(Configuration)\Frameworks\*.*" />
<Steps Include="..\Bin\$(Configuration)\Steps\*.*" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="#(Frameworks)">
<LogicalName>Frameworks.%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
<EmbeddedResource Include="#(Steps)">
<LogicalName>Steps.%(Filename)%(Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
<Message Text="EmbeddedResource - #(EmbeddedResource)" />
</Target>

Categories