Now i am doing like this
LogManager.DisableLogging();
But this need to deploy my code again, how can I disable loggin from nlog configuration file.
<nlog globalThreshold="Off" />
This may help - In the csproj file, you need to add Condition="'$(Configuration)' == 'Debug'" where you include NLog.config Example:
<Project>
...
<ItemGroup>
<Content Include="NLog.config" Condition="'$(Configuration)' == 'Debug'">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
...
</Project>
This way, in release mode it should not log anything because the NLog.config is not included.
Related
In simple F# Azure Functions project host.json not being copied to output in F# Azure Functions project (same local.settings.json) even if specified so in fsharp-azure-functions-signalr-problem.fsproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<RootNamespace>fsharp_azure_functions_signalr_problem</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.0.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.3" />
</ItemGroup>
<ItemGroup>
<Compile Include="negotiate.fs" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Same C# project have no such problem.
Example of my F# project you can git clone https://github.com/ed-ilyin/fsharp-azure-functions-signalr-problem.git
Without host.json file I have following error:
> func start
...
Microsoft.Azure.WebJobs.Host: Error indexing method 'negotiate'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'connectionInfo' to type SignalRConnectionInfo. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
...
So manual copy to compiled folder can solve this problem. I have test the F#, it seems problem comes from your .fsproj file, the definition of host.json should look like this:
<Content Include="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
This work fine on my side.
None Include works too:
<None Include="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
The problem is tracked in this issue.
C# projects by default include all files via a wild card. Thats why Update works. In F# no files are included by default (because file order matters). So there is nothing to update.
I am using aspnet core 3.0 and azure function v3-preview with system.data.sqlclient version 4.7.0
When i try to run azure function(on both service queue trigger and time trigger) it gives below error :
The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. The type initializer for 'System.Data.SqlClient.SNILoadHandle' threw an exception. Unable to load DLL 'sni.dll' or one of its dependencies: The specified module could not be found.
I tried solutions from below links but didn't work:
1. Azure Function - System.Data.SqlClient is not supported on this platform
2. https://github.com/Azure/app-service-announcements-discussions/issues/9
I tried using "Microsoft.Data.SqlClient" for aspnetcore 3.0 But still the same exception occurs while running Azure function on Azure portal.
Please help !
Here is csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.30-beta2" />
<PackageReference Include="runtime.native.System.Data.SqlClient.sni" Version="4.6.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<!-- For publish --><!--
<ItemGroup>
<None Include="$(USERPROFILE)\.nuget\packages\\microsoft.data.sqlclient\1.0.19249.1\runtimes\win\lib\netcoreapp2.1\microsoft.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
--><!-- For local debug --><!--
<Target Name="CopyToBin" BeforeTargets="Build">
<Copy SourceFiles="$(USERPROFILE)\.nuget\packages\microsoft.data.sqlclient\1.0.19249.1\runtimes\win\lib\netcoreapp2.1\microsoft.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
</Target>-->
<ItemGroup>
<None Include="$(USERPROFILE)\.nuget\packages\\system.data.sqlclient\4.7.0\runtimes\win\lib\netcoreapp2.1\system.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="CopyToBin" BeforeTargets="Build">
<Copy SourceFiles="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.7.0\runtimes\win\lib\netcoreapp2.1\system.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
</Target>
</Project>
Please make sure your azure function meet these criteria in this link.
And here is a workaround provided by others, add the following to your .csproj:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\function.deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\function.deps.json" />
</Target>
It worked for me by adding below code in csproj file :
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
</Target>
This line should be taking care of that:
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
reference : github
According to the NuProj documentation,
NuGet supports adding references to framework assemblies as well. You can specify those via the FrameworkReference item:
<ItemGroup>
<FrameworkReference Include="System.dll" />
<FrameworkReference Include="System.Core.dll" />
</ItemGroup>
But when I try this (see below), I am getting what looks like an ArgumentNullException — the generated .nuspec file does contain the correct <frameworkAssembly> elements, however:
1>C:\…\MSBuild\NuProj\NuProj.targets(527,5): error : Value cannot be null.
1>C:\…\MSBuild\NuProj\NuProj.targets(527,5): error : Parameter name: folderName
This is part of my .vbproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
…
<PropertyGroup>
<NuProjPath Condition=" '$(NuProjPath)' == '' ">$(MSBuildExtensionsPath)\NuProj\</NuProjPath>
</PropertyGroup>
<Import Project="$(NuProjPath)\NuProj.props" Condition="Exists('$(NuProjPath)\NuProj.props')" />
<PropertyGroup Label="Configuration">
<Id>SomeProject</Id>
<Version>…</Version>
<Title>…</Title>
…
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SomeProject.vbproj" />
</ItemGroup>
<!-- the next ItemGroup is the one I added manually, as shown in the documentation: -->
<ItemGroup>
<FrameworkReference Include="System.ServiceModel.dll" />
</ItemGroup>
<Import Project="$(NuProjPath)\NuProj.targets" />
</Project>
Am I doing something wrong, or is this a bug with NuProj?
This is an issue with v3.4.3 of Nuget.exe - details here:
https://github.com/NuGet/Home/issues/2648
I was able to resolve this by updating to v3.5.0 - just run > nuget update -self on the command line.
I need to tie together a bunch of steps which include building solutions, projects and running .cmd files using a custom MSBuild file.
My first pass at this is below:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<ItemGroup>
<ProjectsToBuild Include="..\Hosts\solution1.sln"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\solution2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="helper1.csproj"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\Sandboxes\helper2.sln"></ProjectsToBuild>
<Exec Include="" Command="CALL GetFiles.cmd"/>
<ProjectsToBuild Include="wix\proc\prod.wixproj"></ProjectsToBuild>
<Exec Command="CALL final.cmd"/>
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="#(ProjectsToBuild)" Targets="Build">
<Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>
<Message Text="#ProjectOutputs"/>
</Target>
</Project>
This resulted in an error since the Exec element is in the wrong place.
Basically, I need to build solution1.sln, solution2.sln,helper1.csproj and helper2.sln (in sequence), then, run the file GetFiles.cmd, then build prod.wixproj followed by running the final.cmd file.
I have looked at MSDN (here, here, here), a blog, and browsed through various stackoverflow questions (including this, this, this, this), but none of them quite address what I am trying to do. This is the first time I have ever worked with MSBuild, so it is possible I may have missed something. Will appreciate any pointers...
Since an ItemGroup node can be a child of a Target node, break down those ItemGroup members into separate targets, then use the DefaultTargets attribute to control the sequence in which those are built.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Target1;Target2;Target3" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5" >
<Target Name="Target1">
<Message Text="Target 1" />
</Target>
<Target Name="Target2">
<Message Text="Target 2" />
</Target>
<Target Name="Target3">
<Message Text="Target 3" />
</Target>
</Project>
The build projects are already in the correct order see:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<ItemGroup>
<ProjectsToBuild Include="..\Hosts\solution1.sln"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\solution2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="helper1.csproj"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\Sandboxes\helper2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="wix\proc\prod.wixproj"></ProjectsToBuild>
</ItemGroup>
<Target Name="Build">
<Exec Command="CALL GetFiles.cmd"/>
<Message Text="Build order: %(ProjectsToBuild.Identity)"/>
<MSBuild Projects="#(ProjectsToBuild)" Targets="Build">
<Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>
<Message Text="#(ProjectOutputs)"/>
<<Exec Command="CALL final.cmd"/>
</Target>
</Project>
At the start the order of the itemgroup is displayed:
Project "C:\Test\Testcode\build\testcode.msbuild" on node 1 (default targets).
Build:
Build order: ..\Hosts\solution1.sln
Build order: ....\solution2.sln
Build order: helper1.csproj
Build order: ....\Sandboxes\helper2.sln
Build order: wix\proc\prod.wixproj
All done.
I am currently using the inbuilt Publish function within VS2012 to publish an ASP.NET MVC site to a file system directory share on a Web Server. Is there anyway that I can have it publish to multiple locations rather than just the one when I click the Publish button?
I don’t want to have to create a second profile and have to do the same process twice and I have looked at modifying the pubxml file by adding in an additional tag to see if the publish routine picks it up. But unfortunately it just seems to pick up the last configuration in the list.
I know the ideal would be to implement a CI solution but for the time being my hands are tied with the Publish functionality and need to keep it relatively straight forward.
Many thanks
We had the same need of publishing our solution to multiple file share locations, and while the question was asked several months ago I thought that an answer could benefit to the community.
Since VS publish profiles are plain MSBuild files that can easily be extended, here is the solution I came with.
Note that I extracted some code fragments from our build process that is a bit more complex so I do not guarantee that it will all works without having to alter it a bit.
In the publish profile, I added a custom DeploymentPaths item as shown below.
Note that you could define one or more additional locations.
<ItemGroup Label="Defines additional publish locations">
<DeploymentPaths Include="\\SERVER1\ShareFolder\ProjectA\" />
<DeploymentPaths Include="\\SERVER2\ShareFolder\ProjectA\" />
</ItemGroup>
Then I added a custom target CustomWebFileSystemPublish to run after WebFileSystemPublish. This target calls another MSBuild file publish.xml that performs the delete of existing files and copy the new files.
<!-- Custom File System Publish to deploy to additional locations based on DeploymentPaths -->
<Target Name="CustomWebFileSystemPublish" AfterTargets="WebFileSystemPublish" Condition=" #(DeploymentPaths)!='' ">
<CreateItem Include="$(MSBuildProjectDirectory)\$(_PackageTempDir)">
<Output ItemName="AbsoluteSourcePathItem" TaskParameter="Include" />
</CreateItem>
<CreateProperty Value="%(AbsoluteSourcePathItem.Fullpath)">
<Output PropertyName="AbsoluteSourcePath" TaskParameter="Value" />
</CreateProperty>
<Message Text="### CustomWebFileSystemPublish" Importance="high" />
<Message Text="### DeploymentPaths: #(DeploymentPaths)" Importance="high" />
<MSBuild Projects="$(MSBuildProjectFile)" Properties="AbsoluteSourcePath=$(AbsoluteSourcePath)" Targets="DoPublish" />
</Target>
<Target Name="DoPublish">
<Message Text="### DoPublish $(AbsoluteOutputPath) | %(DeploymentPaths.Identity)" Importance="normal" />
<!-- Adjust path to the publish.xml file depending on where you put it in your solution -->
<MSBuild Projects="..\Deployment\publish.xml" Properties="OutputPath=$(AbsoluteSourcePath);DeployPath=%(DeploymentPaths.Identity)" />
</Target>
Finally, here is the publish.xml MSBuild file
<!-- Publish.xml -->
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Start">
<PropertyGroup>
<!-- Ensure DeployPath has the expected trailing slash -->
<DeployPath Condition=" '$(DeployPath)' != '' and !HasTrailingSlash('$(DeployPath)') ">$(DeployPath)\</DeployPath>
</PropertyGroup>
<Message Text=" # Deploying from $(OutputPath) to $(DeployPath) " Importance="normal" />
</Target>
<Target Name="CleanDeployFolder" DependsOnTargets="Start"
Condition=" $(DeployPath)!=''">
<Message Text=" # Cleaning files in $(DeployPath)" Importance="normal" />
<!-- Defines the files to clean -->
<ItemGroup>
<DeployCleanFiles Include="$(DeployPath)\**\*.*" />
</ItemGroup>
<!--Delete files in Deploy folder (folders not deleted by Delete Task)-->
<Delete Files="#(DeployCleanFiles)" />
<Message Text=" # Cleaning files in $(DeployPath) Completed" Importance="normal" />
</Target>
<Target Name="CopyToDeployFolder" DependsOnTargets="CleanDeployFolder"
Condition=" $(DeployPath)!=''">
<Message Text=" # Copying files to $(DeployPath)" Importance="normal" />
<ItemGroup>
<OutputFiles Include="$(OutputPath)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="#(OutputFiles)" DestinationFolder="$(DeployPath)%(OutputFiles.RecursiveDir)" />
<Message Text=" # Copying files to $(DeployPath) Completed" Importance="normal" />
</Target>
<Target Name="Default" DependsOnTargets="CopyToDeployFolder"
Condition=" $(OutputPath)!='' And $(DeployPath)!='' ">
<Message Text=" # Deploying from $(OutputPath) to $(DeployPath) Completed" Importance="normal" />
</Target>
</Project>
You could create a small Windows Service that monitors a Directory and copies to multiple locations when new files are added
Try FileSystemWatcher on MSDN