unfortunately the PC I am working with has no Internet Connection and only Visual Studio Code. So far I have not been able to install the microsoft.entityframeworkcore.3.1.4.nupkg package. So I was thinking about just using the dll but keep everything else in the project like usual.
In my class I want to call:
using Microsoft.EntitiyFrameworkCore;
my csproj file looks like this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" />
</ItemGroup>
<Reference Include="Microsoft.EntityFrameworkCore">
<HintPath>..\Framework\Microsoft.EntityFrameworkCore.dll</HintPath>
</Reference>
</Project>
I also copied the dll to the debug and release folder, as well as the Framework folder. Can someone give me a hint what I am missing? I assume locally add the nupkg package just by a command line without internet and without the full version of Visual Studio is impossible.
Thanks
Stephan
I think I forgot the itemgroup:
<ItemGroup>
<Reference Include="Microsoft.EntityFrameworkCore">
<HintPath>\Framework\Microsoft.EntityFrameworkCore.dll</HintPath>
</Reference>
</ItemGroup>
Related
I have the following project in my solution which I am trying to use to create a NuGet package:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>ExpressionTreeTestObjects</PackageId>
<Authors>Zev Spitz</Authors>
<Company />
<Product>ExpressionTreeTestObjects</Product>
<Description>A set of expression trees, and instances of other types from System.Linq.Expressions, for testing code against a variety of expression trees. The objects are generated by the C# compiler, by the VB.NET compiler, or using the factory methods at System.Linq.Expressions.Expression.</Description>
<Copyright>Copyright (c) 2019 Zev Spitz</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/zspitz/ExpressionTreeToString</PackageProjectUrl>
<RepositoryUrl>https://github.com/zspitz/ExpressionTreeToString</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>expression-tree code-generation visual-basic.net vb.net csharp test-data tostring</PackageTags>
<IncludeBuildOutput>true</IncludeBuildOutput>
<IncludeReferencedProjects>true</IncludeReferencedProjects>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ExpressionTreeTestObjects.VB\TestObjects.VB.vbproj" />
<ProjectReference Include="..\ExpressionTreeTestObjects\TestObjects.csproj" />
</ItemGroup>
</Project>
Build and pack both seem to work. However, the .nupkg file doesn't seem to include the referenced DLLs.
How can I troubleshoot this? How can I resolve it?
I think the solution can be found here:
<Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences">
<ItemGroup>
<BuildOutputInPackage Include="#(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" />
</ItemGroup>
</Target>
I maintain a few tiny Nuget Packages.
I have a Nuget README file in the git repository, and the .nupkg file is auto-built by VS, based on the "Package" config, stored in the .csproj file.
Whenever I need to release a new versio of the package, I upload the .nupkg file to nuget, in the web UI, and then it asks me for any documentation, at which point I have to manually upload the README file.
Is there any way to put that README file in the .nupkg so that I don't have to manually upload it every time?
NuGet have now added support to make this JustWork.
Announcement on the Issue thread: https://github.com/NuGet/Home/issues/6873#issuecomment-833829727
Announcement Blog post: https://devblogs.microsoft.com/nuget/add-a-readme-to-your-nuget-package/
All you need to do is reference the README.md file in the .csproj, using the PackageReadmeFile tag. If the README.md is in the git root (i.e. where GitHub auto-detects it) then it will look like this:
<PackageReadmeFile>README.md</PackageReadmeFile>
Currently there is not a way to do this, but it is WIP.
The new spec under review: https://github.com/NuGet/Home/wiki/Embedding-and-displaying-NuGet-READMEs
This issue for this feature: https://github.com/NuGet/Home/issues/6873
i do this via the csprj. file.
I created a .netstandard project and added a readme.txt.
add following to the x.csproj
<ItemGroup>
<None Include="readme.txt" pack="true" PackagePath="." />
</ItemGroup>
When installing the nuget the first time the file will be displayed in VS.
There is somewhere in the internet a artikel describing the solution, but i cannot find it now.
Here my complete csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net471;net35</TargetFrameworks>
.....
<FileVersion>1.0.1.11</FileVersion>
<AssemblyVersion>1.0.1.11</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NLog" Version="4.7.6" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="readme.txt" pack="true" PackagePath="." />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>
I used Visual Studio 2017 to make a solution with docker-compose support. When I try to pack a nuget package (during a CI process) using dotnet pack MySolution.sln I getting the error MSB4057 saying that it cannot pack the docker-compose.dcproj project. So I tried to use <IsPackable>false</IsPackable> inside my docker-compose.dcproj with no success.
So I have to pack my projects one by one or use different solutions for CI and for debugging process - both solutions looks ugly to me.
Does anyone have an idea how to exclude .dcproj file from trying to been packed by dotnet pack?
In the CI script, remove the docker-compose project from the solution before the pack command with
dotnet sln MySol.sln remove docker-compose.dcproj
I had the same problem and I have solved it by adding a dummy "Pack" target to docker-compose.dcproj, so my project looks like this:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" Sdk="Microsoft.Docker.Sdk">
<PropertyGroup Label="Globals">
<ImportDirectoryBuildProps>false</ImportDirectoryBuildProps>
<ImportDirectoryBuildTargets>false</ImportDirectoryBuildTargets>
<ProjectVersion>2.1</ProjectVersion>
<DockerTargetOS>Windows</DockerTargetOS>
<ProjectGuid>0a1c7d45-3174-4d07-a025-4d5fd55042c0</ProjectGuid>
<IsPackable>false</IsPackable>
<IsTestProject>false</IsTestProject>
</PropertyGroup>
<PropertyGroup>
<DockerServiceName>app-name</DockerServiceName>
</PropertyGroup>
<ItemGroup>
<None Include="docker-compose.override.yml">
<DependentUpon>docker-compose.yml</DependentUpon>
</None>
<None Include="docker-compose.yml" />
</ItemGroup>
<Target Name="Pack">
</Target>
</Project>
I've setup building nuget package from my project using package tab in project options. Everything seems to work except that my nuget package contains stylecop.json file. Build action for this file is set to "C# analyzer additional file". How to get rid of this file from nuget package?
This is my csproj file content
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseUrl>https://github.com/aixasz/ImageShareTemplate/blob/develop/LICENSE</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/aixasz/ImageShareTemplate/</PackageProjectUrl>
<Description>ImageShareTemplate is image template library to share an image to social like facebook, twitter, etc.</Description>
<RepositoryUrl>https://github.com/aixasz/ImageShareTemplate/</RepositoryUrl>
<PackageTags>image socialmedia</PackageTags>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.0-beta0001" />
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0001" />
</ItemGroup>
<ItemGroup>
<Folder Include="Fonts\" />
</ItemGroup>
</Project>
I have created a test project based on .Net Core 2 and wrote some NUnit test cases. After installing necessary NuGet packages i.e. NUnit3TestAdapter, I was able to see all test cases in "Test Explorer" and able to execute those. Now, when I looked into the project directory, I found that it's creating "obj" folder and some json files in it. So I tried to change the path of "obj" folder by modifying ".csproj" file. I provided some different path in the parameter "BaseIntermediateOutputPath" and that way, I was able to get rid of "obj" folder. The reason for providing different path was, I wanted to keep json files separate from source code.
However, after modifying that I am not able to see or execute any test cases from Test Explorer.
Is this a Microsoft bug?
Is any packages having dependency on "obj" folder?
P.S.
I am using "NUnit" and "NSubstitute" packages for my test project.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TargetFramework>netcoreapp2.0</TargetFramework>
<OutputPath>..\..\build\$(Configuration)\UnitTests\</OutputPath>
<BaseIntermediateOutputPath>..\..\work\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<ItemGroup>
<PackageReference Include="Castle.Core" Version="4.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<ItemGroup>
<ProjectReference Include="..\UtilityLibrary\UtilityLibrary.csproj" />
</ItemGroup>
</Project>
When .NET Core projects build, they do not copy all referenced files into the bin folder. When you add Microsoft.NET.Test.Sdk to your test project, one of the things it does is add an AssemblyResolve event handler which loads other dependent assemblies from a list of searchDirectories.
BaseIntermediateOutputPath not working was reported against the VSTest project and is an issue with MSBuild. The workaround is noted in the dotnet sdk repository. From that, you need to use Sdk imports in your csproj instead of the Sdk attribute on the Project element.
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>obj\XXX\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<!-- Body of project -->
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>