I could not get my F# project to write to the TraceSource.
Here was my F# code:
use logFileStream = new FileStream("log.txt", FileMode.Append, FileAccess.Write)
(
use logFileListener = new TextWriterTraceListener(logFileStream)
(
let traceSource = TraceSource("Test", SourceLevels.All)
traceSource.Listeners.Add(logFileListener) |> ignore
traceSource.TraceEvent(TraceEventType.Verbose, 1, "This is a test.")
)
)
Here was my F# project:
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
<PackageReference Include="System.Diagnostics.TextWriterTraceListener" Version="4.3.0" />
<PackageReference Include="System.Diagnostics.Tracing" Version="4.3.0" />
</ItemGroup>
</Project>
Why was log.txt empty?
I needed to add <DefineConstants>TRACE</DefineConstants> to a PropertyGroup within my project file.
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
Related
I get this error building my specflow test project
I cannot figure out why I get these compile bugs..
I am quite sure it has to do with use .NET 5,
don't have a lib folder, where the libraries/nugets are stored...
my project looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows7.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="SpecFlow.Plus.LivingDocPlugin" Version="3.9.57" />
<PackageReference Include="SpecFlow.MsTest" Version="3.9.74" />
<PackageReference Include="MSTest.TestAdapter" Version="2.2.10" />
<PackageReference Include="MSTest.TestFramework" Version="2.2.10" />
<PackageReference Include="FluentAssertions" Version="6.7.0" />
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<OutputPath>..\Bin\Debug</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<OutputPath>..\Bin\Release</OutputPath>
</PropertyGroup>
<ItemGroup>
<Folder Include="Drivers\" />
<Folder Include="Hooks\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MagVenture.Utilities.UI\MagVenture.Utilities.UI.csproj" />
</ItemGroup>
I cannot figure it out... - there is a twirl somewhere that I didn't see..
Disable the NU5100 warning, when treating warnings as errors.
it is due to the .NET framework versions policies about location in lib folder.
I want to exclude ALL files & folders in wwwroot\data from being published to my website folder. The files in my website folder are the latest copy and should never be overwritten when I publish the project.
Reference Microsoft documentation
The documentation indicates using this xml in .csproj file but I can't get it to work. I've tried putting this in both my .csproj file and .pubxml with no success.
What am I doing wrong? Can someone tell me if this actually works?
<ItemGroup>
<MsDeploySkipRules Include="CustomSkipFolder">
<ObjectName>dirPath</ObjectName>
<AbsolutePath>wwwroot\\data</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>
Here is my .pubxml file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>False</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>C:\www\VisualStudio2019-Core3</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>netcoreapp3.1</TargetFramework>
<ProjectGuid>881d6bfb-ed04-41d7-b600-0e26765ff90e</ProjectGuid>
<SelfContained>false</SelfContained>
</PropertyGroup>
Tried putting code here -->>
</Project>
Here is my .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>VisualStudio2019_Core3</RootNamespace>
<UserSecretsId>93d2ec1f-4bcc-4aa5-ad65-4bdbdce5690a</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.2" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="2.19.60" />
</ItemGroup>
Tried putting code here -->>
</Project>
Additional information:
Visual Studio 2019
Web Application Core 3.1
Publishing via Studio menus...not command line.
I used this (referring to my webapp) after end tag PropertyGroup
<ItemGroup>
<Content Remove="appsettings.Development.*" />
<Content Remove="bundleconfig.json" />
<Content Remove="wwwroot\js\Site.js" />
<Content Remove="wwwroot\js\webcam-easy.js" />
<Content Remove="wwwroot\js\webcam-app.js" />
<Content Remove="wwwroot\css\Site.css" />
<Content Update="wwwroot\js\Site.js" CopyToPublishDirectory="Never" />
<Content Update="wwwroot\js\webcam-easy.js" CopyToPublishDirectory="Never" />
<Content Update="wwwroot\js\webcam-app.js" CopyToPublishDirectory="Never" />
<Content Update="wwwroot\css\Site.css" CopyToPublishDirectory="Never" />
<ResolvedFileToPublish Include="wwwroot\css\xxxxx.min.css">
<RelativePath>wwwroot\css\xxxxx.min.css</RelativePath>
</ResolvedFileToPublish>
<ResolvedFileToPublish Include="wwwroot\js\xxxxx.min.js">
<RelativePath>wwwroot\js\xxxxx.min.js</RelativePath>
</ResolvedFileToPublish>
<MsDeploySkipRules Include="connectionconfig">
<ObjectName>filePath</ObjectName>
<AbsolutePath>connection.json</AbsolutePath>
</MsDeploySkipRules>
</ItemGroup>
I am trying to install an existing project in Dotnet core but I was getting the error
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<StartupObject></StartupObject>
<!--<PreserveCompilationContext>true</PreserveCompilationContext>
<MvcRazorCompileOnPublish>true</MvcRazorCompileOnPublish>-->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Boilerplate.AspNetCore" Version="3.0.0" />
<PackageReference Include="BuildBundlerMinifier" Version="2.8.391" />
<PackageReference Include="Captcha" Version="4.4.2" />
<PackageReference Include="linqtotwitter" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNet.Identity.Core" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.1.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="3.2.1" />
</ItemGroup>
Try to update these from the NuGet Package Manager will fix your issue
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
I want to build my NuGet package in one of my TFS build steps.
Because .NET Standard 2.0 is currently not supported by the TFS NuGet step, I am using /t:pack as the build argument in my MSBuild invocation.
When I only use one TargetFramework it is working fine. My assemblies get a version and my NuGet package too.
Even if I am using an AssemblyInfo.cs in .NET Standard 2.0 - explained in this answer.
So far no problem, but if I want to build now on two different TargetFrameworks like <TargetFramework>netstandard2.0;net45</TargetFramework> my NuGet package won't get a Version.
So in the end this is working and is generating a versioned NuGet file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);ReadPackageVersionFromOutputAssembly</GenerateNuspecDependsOn>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<Target Name="ReadPackageVersionFromOutputAssembly" DependsOnTargets="Build">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="PackAssembly" />
</GetAssemblyIdentity>
<PropertyGroup>
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>
<ItemGroup>
<Compile Remove="AccessControl\**" />
<EmbeddedResource Remove="AccessControl\**" />
<None Remove="AccessControl\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\common\Version.cs" Link="Properties\Version.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.8.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="MyEngine">
<HintPath>..\libs\NetStandard\MyEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
So here is my current .csproj file. This builds too and also generates a NuGet file. But in this case my NuGet file is unversioned. Why is it this way and how can I fix it?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GenerateNuspecDependsOn>$(GenerateNuspecDependsOn);ReadPackageVersionFromOutputAssembly</GenerateNuspecDependsOn>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<Target Name="ReadPackageVersionFromOutputAssembly" DependsOnTargets="Build">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="PackAssembly" />
</GetAssemblyIdentity>
<PropertyGroup>
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>
<ItemGroup>
<Compile Remove="AccessControl\**" />
<EmbeddedResource Remove="AccessControl\**" />
<None Remove="AccessControl\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\common\Version.cs" Link="Properties\Version.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.8.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<Reference Include="MyEngine">
<HintPath>..\libs\NetStandard\MyEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<Reference Include="MyEngine">
<HintPath>..\libs\NET45\MyEngine.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
The targets can be adapted to support multi-targeting like this:
<Target Name="ReadPackageVersionFromOutputAssemblySingleTfm" Returns="#(PackAssembly)" Condition="'$(IsCrossTargetingBuild)' != 'true'">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="PackAssembly" />
</GetAssemblyIdentity>
<PropertyGroup>
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>
<Target Name="ReadPackageVersionFromOutputAssemblyMultipleTfms" Condition="'$(IsCrossTargetingBuild)' == 'true'">
<PropertyGroup>
<FirstTargetFramework>$([System.String]::Copy($(TargetFrameworks)).Split(';').GetValue(0))</FirstTargetFramework>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)" Targets="ReadPackageVersionFromOutputAssemblySingleTfm" Properties="TargetFramework=$(FirstTargetFramework)">
<Output TaskParameter="TargetOutputs" ItemName="PackAssembly" />
</MSBuild>
<PropertyGroup>
<PackageVersion>%(PackAssembly.Version)</PackageVersion>
</PropertyGroup>
</Target>
<Target Name="ReadPackageVersionFromOutputAssembly" DependsOnTargets="Build;ReadPackageVersionFromOutputAssemblySingleTfm;ReadPackageVersionFromOutputAssemblyMultipleTfms" />
I have an asp.net mvc 3 project and a separate BusinessLayer project included in the solution. When I'm trying to deploy my site to Azure via local git repository, I'm getting the following error: '<remote_path>\BusinessLayer\BusinessLayer.csproj' is not a deployable project.. No other information is provided in logs. Site perfectly deploys on my local server. So I want to know at least some possible reasons why this error occurs. Thanks in advance.
Here's my .csproj file, if necessary:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{31F2F6FE-10D8-4510-AC61-CBE1962D3940}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BusinessLayer</RootNamespace>
<AssemblyName>BusinessLayer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="MongoDB.Bson">
<HintPath>..\..\Libs\MongoDB.Bson.dll</HintPath>
</Reference>
<Reference Include="MongoDB.Driver">
<HintPath>..\..\Libs\MongoDB.Driver.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Battle.cs" />
<Compile Include="BattleManager.cs" />
<Compile Include="BattlePlace.cs" />
<Compile Include="Helpers\ConvertHelper.cs" />
<Compile Include="Helpers\ImageHelper.cs" />
<Compile Include="Message.cs" />
<Compile Include="Picture.cs" />
<Compile Include="Place.cs" />
<Compile Include="PlaceManager.cs" />
<Compile Include="Subject.cs" />
<Compile Include="User.cs" />
<Compile Include="Helpers\DBHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
You may need to tell Azure exactly which project it should deploy, which you can do using a .deployment file at the root of your project. e.g.
[config]
project = WebProject/WebProject.csproj
Please see this page for more information about this.
Sounds like you're trying to deploy the BusinessLayer project and not the Website project. As long as your MVC site project has a reference to BusinessLayer, just deploy the website. BusinessLayer will be included as a reference.
You can't deploy BusinessLayer by itself, as it is a library and not an application.