About Hasmukh patel

- Hasmukh Patel
- Harrow, London, United Kingdom
- Dot-Net developer with expertise in Web, WPF, Win-form applications. Have worked on Asp.net,mvc , WPF and Win-forms projects in c#.net language having Sql-Server/Oracle as database with service oriented architecture using test driven development. Having complete knowledge of SDLC and have successfully worked and implemented it on projects.
Software licenses
List of open source which allows you to use, modify or share with or without restrictions.
Apache License
The Apache License is a permissive free software license written by the Apache Software Foundation. It allows users to use the software for any purpose, to distribute it, to modify it, and to distribute modified versions of the software under the terms of the license, without concern for royalties. Wikipedia
GNU Lesser General Public License - LGPL
The GNU Lesser General Public License is a free-software license published by the Free Software Foundation. Wikipedia
Mozilla Public License
The Mozilla Public License is a free and open source software license developed and maintained by the Mozilla Foundation. Wikipedia
BSD licenses
BSD licenses are a family of permissive free software licenses, imposing minimal restrictions on the use and distribution of covered software. This is in contrast to copyleft licenses, which have share-alike requirements. Wikipedia
MIT License
The MIT License is a permissive free software license originating at the Massachusetts Institute of Technology in the late 1980s. As a permissive license, it puts only very limited restriction on reuse and has, therefore, high license compatibility. It is compatible because it can be re-licensed under other licenses. Wikipedia
GNU General Public License
The GNU General Public License is a series of widely used free software licenses that guarantee end users the freedom to run, study, share, and modify the software. Wikipedia
Useful liks
Build Nuget Package with Dotnet core and New style VS2017 csproj
Create a new class library project using CLI
dotnet new classlib -o MyLibrary
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netstandard2.0</TargetFramework> </PropertyGroup> </Project>
Now add package details to build as a nuget package on project file
<PropertyGroup>
<TargetFramework>netstandard2.0;</TargetFramework>
<PackageId>SampleLibrary</PackageId>
<Version>0.1</Version>
<Description>My SampleLibrary</Description>
<Copyright>My Company</Copyright>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
</PropertyGroup>
IsPackable & GeneratePackageOnBuild are required to build as a .nupkg file.
If you want to Target Multiple Frameworks
change TargetFramework to TargetFrameworks and add ';' between frameworks
<TargetFrameworks>netstandard2.0;net452;net48;</TargetFrameworks>
Add a project reference
<ItemGroup>
<ProjectReference Include="..\ClassLibrary2\ClassLibrary2.csproj" />
</ItemGroup>
Include framework references
<ItemGroup> <!-- keep references unless they are to package files. See the section about the NuGet upgrade below. --> <Reference Include="System.Configuration" /> </ItemGroup>Include file as a content
<ItemGroup> <Content Include="Js\JavaScript1.js" /> </ItemGroup>Add a nuget package
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.2" />
</ItemGroup>
Add pdb file into nupkg
Add the following line into the
<PropertyGroup>
element
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
Compile project
At this stage, project with compile and you will see package file in
bin\Debug\SampleLibrary.0.1.0.nupkg folder, when open nupkg with an archive tool like Winzip,7Zip or Winrar,
ClassLibrary2 dll will not be included in the nupkg file.
To Fix this issue
Add the following line into the
<PropertyGroup>
element
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
Add new target between
<project>
tags
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"/>
</ItemGroup>
</Target>
Include extra files into build
<!-- the defaults -->
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
include there lines into csproj file.
<ItemGroup>
<Content Include="**\*.js" />
</ItemGroup>
Filly working csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;</TargetFrameworks>
<PackageId>SampleLibrary</PackageId>
<Version>0.1</Version>
<Description>My SampleLibrary</Description>
<Copyright>My Company</Copyright>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<Content Include="**\*.js" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ClassLibrary2\ClassLibrary2.csproj" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Target DependsOnTargets="ResolveReferences" Name="CopyProjectReferencesToPackage">
<ItemGroup>
<BuildOutputInPackage Include="@(ReferenceCopyLocalPaths->WithMetadataValue('ReferenceSourceTarget',
'ProjectReference'))" />
</ItemGroup>
</Target>
</Project>
Upgrad MvcApplication.csproj new VS 2017 style
There is a bunch of open issues on GitHub regarding support of new csproj format for ASP.NET (non-Core) applications. Some of them:
- Using the new .Csproj without .Net core #1688
- Add support for ASP.NET (non-Core) projects #2670
- Support for "classic" ASP.NET #1978
As you probably already understood, new csproj format is not yet supported for ASP.NET applications. It's possible to make it work, however it won't be smooth.
Some time ago I have tried to create ASP.NET MVC project in new csproj format, just for fun. I made it work, however I had not played with it a lot. So it will be interesting to know your experience.
The steps are following:
- Remove old unrequired project files:
- MvcApplication.csproj
- MvcApplication.csproj.user
- packages.config
- Create new MvcApplication.csproj with the following content:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net461</TargetFramework> </PropertyGroup> <PropertyGroup> <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath> <OutputPath>bin\</OutputPath> </PropertyGroup> <ItemGroup> <PackageReference Include="Antlr" version="3.4.1.9004" /> <PackageReference Include="bootstrap" version="3.0.0" /> <PackageReference Include="jQuery" version="1.10.2" /> <PackageReference Include="jQuery.Validation" version="1.11.1" /> <PackageReference Include="Microsoft.ApplicationInsights" version="2.2.0" /> <PackageReference Include="Microsoft.ApplicationInsights.Agent.Intercept" version="2.0.6" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" version="2.2.0" /> <PackageReference Include="Microsoft.ApplicationInsights.PerfCounterCollector" version="2.2.0" /> <PackageReference Include="Microsoft.ApplicationInsights.Web" version="2.2.0" /> <PackageReference Include="Microsoft.ApplicationInsights.WindowsServer" version="2.2.0" /> <PackageReference Include="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="2.2.0" /> <PackageReference Include="Microsoft.AspNet.Mvc" version="5.2.3" /> <PackageReference Include="Microsoft.AspNet.Razor" version="3.2.3" /> <PackageReference Include="Microsoft.AspNet.Web.Optimization" version="1.1.3" /> <PackageReference Include="Microsoft.AspNet.WebPages" version="3.2.3" /> <PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.5" /> <PackageReference Include="Microsoft.CSharp" Version="4.4.1" /> <PackageReference Include="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" /> <PackageReference Include="Microsoft.Net.Compilers" version="2.1.0" developmentDependency="true" /> <PackageReference Include="Microsoft.Web.Infrastructure" version="1.0.0.0" /> <PackageReference Include="Modernizr" version="2.6.2" /> <PackageReference Include="Newtonsoft.Json" version="6.0.4" /> <PackageReference Include="Respond" version="1.2.0" /> <PackageReference Include="WebGrease" version="1.5.2" /> </ItemGroup> <ItemGroup> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /> </ItemGroup> <ItemGroup> <Reference Include="System.Web" /> </ItemGroup> <ItemGroup> <Compile Update="Global.asax.cs"> <DependentUpon>Global.asax</DependentUpon> </Compile> </ItemGroup> <ItemGroup> <Content Include="Web.config"> <SubType>Designer</SubType> </Content> <Content Include="Web.*.config"> <DependentUpon>Web.config</DependentUpon> <SubType>Designer</SubType> </Content> </ItemGroup> </Project>
The long package list above includes default packages added for default ASP.NET MVC application. You should add other packages used by your application.Don't forget to add theMicrosoft.CSharp
package, otherwise you'll get following compilation error onViewBag
assignments:error CS0656: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo.Create'In ASP.NET projects,Microsoft.CSharp
is added as reference to the project. But it's better to consume it as NuGet package.The only direct reference that could not be avoided is aSystem.Web
. - Debugging the projectYou were right when said that debugging could be a pain. Since Visual Studio does not know it's an ASP.NET application, there is no instant method to start debugging session.I see 2 possible solutions here:a. Use IIS Express for debugging.It's quite easy to configure debugging based on IIS Express executable. Just create the following debugging profile:Corresponding launchSettings.json:
{ "profiles": { "ASP.NET Old csproj": { "commandName": "Executable", "executablePath": "c:\\Program Files\\IIS Express\\iisexpress.exe", "commandLineArgs": "/path:\"$(SolutionDir)$(ProjectName)\" /port:12345" } }
b. Use IIS for debugging.In IIS Manager create application that points to directory with your project. Now you could debug your application by attaching tow3wp.exe
process.
Here is Sample Project on GitHub. It is basically default ASP.NET MVC project migrated to new csproj format following above steps. It could be compiled, executed and debugged (profile for IIS Express included)
Coped from a stackoverflow question
Coped from a stackoverflow question
Subscribe to:
Posts
(
Atom
)