I'm working on multi module Maven project, i built in cmd using mvn clean install/deploy and the build is successful, all the class files in target\class folder are generated.
But when i import this project in VS Code, while opening the projects it is deleting all the class files i.e it deletes target\classes folder in all the projects.
And, VS code doesn't resolve the dependencies in java files until the file is opened.
How do I fix this?
So, when the all the class files are deleted, it is unable to debug the code. While I try to run the code, it shows following error:
Error: Could not find or load main class com.application.Main
Caused by: java.lang.ClassNotFoundException: com.application.Main
Related
My solution consists of a main web app, with several azure web jobs attached to it. When I go to publish the main web app, I receive this error:
[project_path]\[project_name].csproj(0,0): Error MSB4057: The target "AddScheduledJob" does not exist in the project.
I'm not sure where AddScheduledJob is coming from. It is not the name of any project in the solution.
I think I have tracked down the file that is "attempting" to reference this phantom project:
[solution_path]\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets
This file contains this snippet of text:
<Target Name="AddScheduledJob"
DependsOnTargets="$(AddScheduledJobDependsOn)"
AfterTargets="MSDeployPublish"
Condition="'$(FilePreview)' == 'false' and ('$(WebJobPublishFromWAP)' == 'true' or '$(_DestinationType)' == 'AzureWebSite')">
<CreateScheduledWebJob JobConfig="#(JobConfig)"
WebSiteName="$(WebSiteName)"
WebSiteUrl="$(WebSiteUrl)"
ManagementUri="$(WebJobManagementUri)"
ManagementCertificatePath="$(ManagementCertificatePath)"
ManagementCertificatePassword="$(ManagementCertificatePassword)"
ManagementCertificate="$(ManagementCertificate)"
ManagementToken="$(ManagementToken)"
PublishSettingsPath="$(PublishSettingsPath)"
SubscriptionId="$(SubscriptionId)"
Condition="'%(RunMode)' == 'Scheduled'"/>
I have no idea where this is coming from, or why it is causing a problem. I am tempted to just remove that snippet, but at the top of the file, I read this snippet:
WARNING: DO NOT MODIFY this file, this file is added to your project automatically...
Can I safely remove this snippet from the "webjobs.console.targets" file? Or, is there something else that might be going on?
UPDATE
I discovered that even with this error, my web app is successfully getting published. Here is a more in-depth view of the logs at the end of the publish process:
Adding ACLs for path (ringclone-test/App_Data)
Publish Succeeded.
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(25,3): Warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.console.targets (25,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\APD\RingClone\TicketProcessor\TicketProcessor.csproj]
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(25,3): Warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.console.targets (25,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\APD\RingClone\TicketDistributor\TicketDistributor.csproj]
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(25,3): Warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.console.targets (25,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\APD\RingClone\ArchiveIndexer\ArchiveIndexer.csproj]
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(25,3): Warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.1.0\tools\webjobs.console.targets (24,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\APD\RingClone\Starter\Starter.csproj]
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(25,3): Warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.1.0\tools\webjobs.console.targets (24,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\APD\RingClone\NrtTrigger\NrtTrigger.csproj]
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(25,3): Warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.console.targets (25,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\APD\RingClone\DownloadProcessor\DownloadProcessor.csproj]
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(25,3): Warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.1.0\tools\webjobs.console.targets (24,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\APD\RingClone\DatabaseReIndexer\DatabaseReIndexer.csproj]
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(110,5): Error : An error occurred while creating the WebJob schedule: Webjob configuration is missing metadata for StartTime
C:\APD\RingClone\DailyMaintenance\DailyMaintenance.csproj(0,0): Error MSB4057: The target "AddScheduledJob" does not exist in the project.
C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.7\tools\webjobs.console.targets(25,3): Warning MSB4011: "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\WebApplications\Microsoft.WebApplication.targets" cannot be imported again. It was already imported at "C:\APD\RingClone\packages\Microsoft.Web.WebJobs.Publish.1.0.12\tools\webjobs.console.targets (25,3)". This is most likely a build authoring error. This subsequent import will be ignored. [C:\APD\RingClone\ScheduledTrigger\ScheduledTrigger.csproj]
As you can see, it says "publish succeeded", then complains about the "StartTime" for one of the jobs. And then complains about the "AddScheduledJob". I'm not concerned about the "StartTime" issue. I can get that fixed. But the error about the project called "AddScheduledJob" is baffling. Even though the publish seems to happen, I don't want this error cluttering up the log. What is causing this error?
That's an ancient NuGet package. In older versions, Visual Studio would allow you to configure the schedule of a webjob if you configured it to run on a schedule instead of continuously. You can remove that target and configure the schedule using the following guidance: https://learn.microsoft.com/en-us/azure/app-service/web-sites-create-web-jobs#CreateScheduledCRON . If you're using an older version of Visual Studio, please upgrade so that you have the latest WebJob project template.
First, you have to add the Microsoft.Web.WebJobs.Publish package from Nuget. Even though VS has the publish to Web Job action, it doesn’t automatically add that package to your project. You could refer to this blog.
Once you add it, you’re still screwed. VS doesn’t automatically modify your .csproj file to use this package.
To do so, you need manually hack your .csproj file. Easiest way is to unload it in VS and add the following line right after the CSharp targets – I’ve included it below for context:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Web.WebJobs.Publish.1.0.11\tools\webjobs.targets"
Condition="Exists('..\packages\Microsoft.Web.WebJobs.Publish.1.0.11\tools\webjobs.targets')" />
Here is a similar issue with you. When he add a new WebJob under asp.net site, retain the newer version of Microsoft.Web.WebJobs.Publish package.
Windows 10
Visual Studio 2017
TeamCity 2017.1.2
GitHub
I'm working with a VS solution that locally behaves as expected. Main-project has some package dependencies. Test-project has project-ref to main project. VS local compile succeeds. Main-project refs + dependencies are copied to MyProject/bin/debug; test-project refs + dependencies are copied to MyProject.Tests/bin/debug; ReSharper local run of tests succeeds.
However my TC project has problems running tests.
My build-config steps are : pull from GitHub , run Visual Studio (sln) build , trigger NUnit.ConsoleRunner to run tests vs built assembly - which throws a file not found error (can't find package dependency assembly ) that perhaps indicate the build steps needs to save as artifact the dependent assembly and copy it to the test output dir.
However looking at the agent work dir I find the dependency assembly present in both the main-project and the test-project :
C:\TeamCity\buildAgent\work\64f706c42d79250c\{main-project}\bin\Debug\{dependency}.dll
and
C:\TeamCity\buildAgent\work\64f706c42d79250c\{tests-project}\bin\Debug\{dependency}.dll
which indicates that VS build step copied {dependency}.dll into bin as expected.
So why can't NUnit find it ?
[19:27:48][Step 5/5] MyProject.dll
[19:27:48][MyProject.dll] MyProject.UnitTests.MyTest
[19:27:49][MyProject.UnitTests.MyTest] System.IO.FileNotFoundException : Could not load file or assembly 'MyProjectDependency, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
[19:27:49]
[MyProject.UnitTests.MyTest] at ReferencingCode()
at MyProject.MyClass.Answer() in C:\TeamCity\buildAgent\work\64f706c42d79250c\MyProject\MyClass.cs:line 9
at MyProject.UnitTests.MyTest() in C:\TeamCity\buildAgent\work\64f706c42d79250c\MyProject\UnitTests.cs:line 10
[19:27:51][Step 5/5] Failed tests detected
I'm wondering if the output dirs are different for the VS Build and NUnit steps ? But my agent work dir is identical to my local VS solution dir - so where would TC be locating the NUnit work dir ?
It looks as if you have two completely separate output directories, one under the test project and one under the main project. Your tests, of course, are run in the directory that contains the test assembly.
The output messages seem to say that the main assembly is being copied into the test assembly directory - the reference from the test project must call for a local copy. We can tell that because the test assembly and the main assembly both have entries in your stack trace. The dependent assembly, however, is probably not referenced by your tests, and so does not get copied. At least that's how I read it - verify by looking at the directory contents.
You could solve this by using the same output directory for everything, but that would probably involve changing the directory structure you are using. A simple fix is to add a reference to the dependent assembly to your test project and set local copy true.
For your tests to run, locally or in TeamCity, your test project must have a project reference to the project you are testing. It does not work any other way. How else would it know what to test? So check your references in the test project, and make sure the output is the same place when the build runs as "Debug" and "Release".
On a side note, letting TC do the actual build and test is fine for simple stuff but it's very hard to troubleshoot. I recommend you build a PowerShell script with PSake and create a "Test" task. That way you can run the script locally and TeamCity can use the same script you are running locally.
I've got a Class Library project and a Console project. Inside the Class Library project there's a folder called "ConfigSettings" containing a configuration file that's referenced by the App.config file. Its "Copy to Output Directory" is set to "Copy Always".
The Console project references this Class Library project. When the console project is built, the ConfigSettings folder is created in the correct place along with the external config file. However, every time I Debug the Console project, the external config file is deleted. The ConfigSettings folder however is left untouched. If I mark the file as read-only it is not deleted, and warning appears in Visual Studio's Error List:
Warning Unable to delete file "C:\<path>\<app>\bin\Debug\ConfigSettings\settings.config". Access to the path 'C:\<path>\<app>\bin\Debug\ConfigSettings\settings.config' is denied.
Is there a setting I can change that will prevent VS from removing this file when I Debug the project? I am using Visual Studio 2015.
This might not be the best solution possible, but I found here, if you do a "Clean solution" just before executing your solution, the files will remain.
I have a Visual Studio solution that contains 16 C# projects. I also have a separate build.proj file which contains three <Target>s:
Build, which contains an <MSBuild> reference to the *.sln
Package, which contains the <MakeDir> and <CopyCommands> to copy the built DLL/EXE files along with various data files to a $(StagePath) directory.
Deploy, that copies files from the stage path to a deploy path.
I was able to run the command xbuild /t:Deploy build.proj to build the *.sln and copy its files to the appropriate location, until recently when IT decided to move my Documents folder onto a network drive.
Now, whenever I try to run this xbuild command, I get several errors like the one below. (The reference is to one of the dependencies within the same solution.)
error CS0234: The type or namespace name `Util' does not exist in the namespace `Contoso'. Are you missing an assembly reference?
But whenever I do a “Build All” on the same *.sln from Xamarin Studio, I get a successful build with 0 errors and 0 warnings. So why can't xbuild find these assembly references if Xamarin Studio can?
I installed the VS2010 web publishing updates yesterday, and now whenever I try to load a WiX setup project (all showing as unloaded in solution explorer) I'm getting the error:
The imported project "PROJECTNAME.wpp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk. C:\Program Files\MSBuild\Microsoft\VisualStudio\v10.5\Web\Microsoft.Web.Publishing.targets
Where PROJECTNAME is the path to my setup wixproj file, without the .wixproj extension. I've checked through the project file and there is no reference to a wpp.targets file anywhere. I decided to try and create a blank targets file in that location and so added one with just this in it:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>
But got exactly the same error - a not found exception despite the file being there!
I then dug into the Microsoft.Web.Publishing.targets file and had a look for any ".wpp.targets" text, which gave me this:
<PropertyGroup Condition="'$(EnableWebPublishProfileFile)'=='true' And
'$(WebPublishProfileFile)' != '' And Exists($(WebPublishProfileFile)) ">
<WebPublishProfileCustomizeTargetFile Condition="'$(WebPublishProfileCustomizeTargetFile)'==''">
$([System.IO.Path]::ChangeExtension($(WebPublishProfileFile), '.wpp.targets'))
</WebPublishProfileCustomizeTargetFile>
...
So that looks to be setting up a filename of PROJECTNAME.wpp.targets, but only when the EnableWebPublishProfileFile property is set to true. I added this to my wixproj file's main propertygroup:
<EnableWebPublishProfileFile>False</EnableWebPublishProfileFile>
Again though, it made no difference at all to the error. I'm running out of ideas here now!
Further update
I've been trying to repo this on a blank project (so far without success), and the messing about has narrowed the error down to this line (186) in the Microsoft.Web.Publishing.targets file:
<Import Project="$(WebPublishPipelineCustomizeTargetFile)"
Condition="'$(WebPublishPipelineCustomizeTargetFile)' != ''"/>
This is set at the top of the file:
<WebPublishPipelineCustomizeTargetFile
Condition="'$(WebPublishPipelineCustomizeTargetFile)'==''">
$(WebPublishPipelineProjectDirectory)\*.wpp.targets
</WebPublishPipelineCustomizeTargetFile>
I'm not sure how this is getting changed to PROJECTNAME.wpp.targets though?
I tried overriding this in my project file, but once again, it makes no difference at all.
Next I added an Exists() condition to the line in the targets file, now some projects are working and others are not, instead failing (on build) with the error:
The "DisableEscapeMSBuildVariable" parameter is not supported by the "ImportParametersFile" task. Verify the parameter exists on the task, and it is a settable public instance property.
My journey continues...
I experienced the same issue when trying to open a standard web project.
The proj file was referencing the following import for v10.0 targets but throwing the import error in the question which referred to v10.5 targets.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" />
The same was true when I referenced a hard coded path - I still got v10.5 error
My solution was to simply back up and remove that version located at:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\10.5
I'm really not sure what other programs and projects need this version or why import paths were not followed but it go this project open for me seeming falling back to the correct version.